From: Daniel S. <dsc...@sc...> - 2012-05-15 21:07:24
|
What about something like %{ static uint32_t SWIG_MY_BIT = MY_BIT; %} %rename(MY_BIT) SWIG_MY_BIT; extern const uint32_t SWIG_MY_BIT; Something very similar to this worked well in my project. You might even be able to define a macro to generate all this, though I'm not that familiar with writing Swig macros. -- Daniel From: Bob Hood [mailto:bh...@co...] Sent: Tuesday, May 15, 2012 1:04 PM To: swi...@li... Subject: Re: [Swig-user] Swig pre-processor and macros defined by macros On 5/15/2012 12:50 PM, Jason Dictos wrote: We've got this simple BIT macro in C we use to define a bit easily: #define BIT(x) ((uint32_t)((uint32_t)1l << ((uint32_t)x))) Lots of our bit flags are defined like this, and we're trying to have swig automatically pick up these definitions, e.g.: #define MY_BIT BIT(0) // bit 0 Problem is, swig for some reason never picks up these definitions. Is there a way to get this to work without going through and eliminating the BIT macro? If I'm not mistaken (at least in terms of 2.0.4), SWIG does not process parameterized pre-processor macros. You'll have to provide a suitable substitute as either a C++ helper function, or a function in your target language, to replace it. Render me gone, ||| Bob ^(===)^ ---------------------------------oOO--(_)--OOo-------------------------- ------- I'm not so good with advice...can I interest you in a sarcastic comment? |