From: Bill C. <ll...@co...> - 2005-12-22 22:37:22
|
g'day wes, Wes Hodges wrote, On 12/22/05 16:49: > i'm guessing this is a C/C++ parsing limitation of SWIG, but, just to > be sure, i'll ask the masters. if i have the following function: > > void [modifier] foo( ); > > where [modifier] is __stdcall or APIENTRY or WINAPI (yes, i'm in > Windows here, and essentially mapping function pointers to OpenGL > extension functions), and i have the following function pointer > typedef: > > typedef void ([modifier] * FOO_FUNC_PTR) ( ); > > when i SWIG it, SWIG reports a C/C++ syntax error. it doesn't like > the [modifier] in the typedef. so, parsing limitation? and, if so, > are there plans to handle it in future versions? i'm guessing no, > since it's a pretty uncommon typedef... no, your code is non-standard C/C++. SWIG is only designed to parse standard C/C++. this is quite a common question, and should be in the FAQ if it isn't already. [workaround:] > #ifdef _SWIG > #undef APIENTRY > #define APIENTRY > #endif > > in my C++ project file, _SWIG is *not* defined (i.e. it builds the > C++ stuff with APIENTRY set). in my SWIG command line compilation > statement, _SWIG *is* set (-D_SWIG switch). this is a good solution, however why not just use #ifdef SWIG? that, after all, is one of the reasons the macro SWIG is defined by SWIG when it is parsing an interface file. often, you don't even need to modify the header. simply create your interface file as such: """ %module blah #define APIENTRY %ignore ...; // whatever you want SWIG to ignore in blah.h %include "blah.h" """ cheers, /lib -- /lib BillClarke PostdoctoralFellow CompSci ANU cs.anu.edu.au/CC-NUMA http://llib.cjb.net ll...@co... tel:+61-2-6125x5687 fax:x0010 PGPid:B381EE7DB7D3E58F17248C672E2DA124ADADF444 GNU unix LaTeX XPilot Buffy DrWho Goodies StarTrek XFiles Origami SML SMP MPI mozilla tcsh Asimov Bear Clarke Donaldson Volleyball Ultimate Cricket emacs C++ X Jordan Kay Lackey Martin Stasheff DeepPurple H&C KLF Queen PinkFloyd |