Add -namespace option to use unique prefix for all wrappers

Using this option allows to prefix all exported symbols (functions,
enums and enum elements) with a prefix based on the given namespace.

Note that (global) variables can't be exported directly when using the
global namespace prefix, even if they are of C-compatible type.
This commit is contained in:
Vadim Zeitlin 2021-10-31 00:38:57 +02:00
commit 6833ead6ed
2 changed files with 75 additions and 16 deletions

View file

@ -132,6 +132,11 @@ $ swig -c -help
<th>C specific options</th>
</tr>
<tr>
<td>-namespace &lt;nspace&gt;</td>
<td>Generate wrappers with the prefix based on the provided namespace, e.g. if the option value is <tt>outer::inner</tt>, the prefix <tt>outer_inner_</tt> will be used. Notice that this is different from using SWIG <tt>nspace</tt> feature, as it applies the the prefix to all the symbols, regardless of the namespace they were actually declared in. Notably, this allows to export instantiations of templates defined in the <tt>std</tt> namespace, such as <tt>std::vector</tt>, using a custom prefix rather than <tt>std_</tt>.</td>
</tr>
<tr>
<td>-noexcept</td>
<td>generate wrappers with no support of exception handling; see <a href="#C_exceptions">Exceptions</a> chapter for more details </td>