KenzieMac130 / ogre-procedural

Automatically exported from code.google.com/p/ogre-procedural
0 stars 0 forks source link

Swig doesn't support different variations of threading support with Ogre #139

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Here's my conversation with swig-user mailing list.
It should help finding a solution :

In a SDK I'm binding to, there's an optionnal threading support, which can vary 
according to how the sdk was built.

So, there's a main header which include the correct header depending on 
situation:

#if OGRE_THREAD_PROVIDER == 0
    #include "OgreThreadDefinesNone.h"
#elif OGRE_THREAD_PROVIDER == 1
    #include "OgreThreadDefinesBoost.h"
#elif OGRE_THREAD_PROVIDER == 2
    #include "OgreThreadDefinesPoco.h"
#elif OGRE_THREAD_PROVIDER == 3
    #include "OgreThreadDefinesTBB.h"
#endif

But swig doesn't follow #include in %include (there's a global switch, but I 
don't want to enable it).

What can I do in interface file?
Is there a way to have optional or conditional %include ?

In the first case, I would just do that (only the header which corresponds to 
the chosen option is included in the SDK) :
%include "OgreThreadDefinesNone.h"
%include "OgreThreadDefinesBoost.h"
%include "OgreThreadDefinesPoco.h"
%include "OgreThreadDefinesTBB.h"

-----------------------------

Conditional %includes can be done the same as conditional #include in C... the 
preprocessor. SWIG has support for the preprocessor, so you'd code it up with 
#if or #ifdef statements, much like you have done above.

Original issue reported on code.google.com by michael.broutin@gmail.com on 29 Jan 2013 at 8:26

GoogleCodeExporter commented 8 years ago

Original comment by michael.broutin@gmail.com on 29 Jan 2013 at 9:58