Expand __declspec documentation
This commit is contained in:
parent
aebc9379ed
commit
7178bb11d3
1 changed files with 33 additions and 2 deletions
|
|
@ -387,10 +387,11 @@ Include it like you would any other interface file, for example:
|
|||
|
||||
__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,
|
||||
|
|
@ -398,12 +399,42 @@ to include the definition explicitly. For example, if you had a header file,
|
|||
file might look like:</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
// bar.i
|
||||
%module bar
|
||||
%include <windows.i>
|
||||
%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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue