Navigation Menu

Skip to content

Commit

Permalink
Expand __declspec documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
wsfulton committed Apr 14, 2015
1 parent aebc937 commit 7178bb1
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions Doc/Manual/Windows.html
Expand Up @@ -387,23 +387,54 @@ <H2><a name="Windows_interface_file"></a>3.4 Microsoft extensions and other Wind

__declspec(dllexport) ULONG __stdcall foo(DWORD, __int32);
</pre></div>

<p>Note that if you follow Microsoft's recommendation of wrapping the
<tt>__declspec</tt> calls in a preprocessor definition, you will need to
make sure that the definition is included by SWIG as well, whether you define it
manually or it is included in a header. For example, if you have specified the
make sure that the definition is included by SWIG as well, by either defining it
manually or via a header. For example, if you have specified the
preprocessor definition in a header named <tt>export_lib.h</tt> and include
other headers which depend on it, you should use the <tt>%include</tt> directive
to include the definition explicitly. For example, if you had a header file,
<tt>bar.h</tt>, which depended on <tt>export_lib.h</tt>, your SWIG definition
file might look like:</p>

<div class="code"><pre>
// bar.i
%module bar
%include &lt;windows.i&gt;
%include "export_lib.h"
%include "bar.h"
</pre></div>

<p>
where export_lib.h may contain:
</p>

<div class="code"><pre>
// export_lib.h
#define BAR_API __declspec(dllexport)
</pre></div>

<p>
and bar.h may look like:
</p>

<div class="code"><pre>
// bar.h
#include "export_lib.h"
BAR_API void bar_function(int, double);
</pre></div>

<p>
Using the preprocessor to remove BAR_API is a popular simpler solution:
</p>

<div class="code"><pre>
// bar.i
%module bar
#define BAR_API
%include "bar.h"
</pre></div>

</body>
</html>

0 comments on commit 7178bb1

Please sign in to comment.