From: William S F. <ws...@fu...> - 2006-12-29 10:22:54
|
Nitro wrote: > Am 28.12.2006, 20:11 Uhr, schrieb Bo Peng <be...@gm...>: > >> Dear list, >> >> I need to use uint16_t (or __int16 for msvc) for my python module. I >> have two problems to process my header files with swig 1.3.31. >> >> 1. In my header file, I have something like >> >> #ifdef _MSC_VER >> typedef __int16 INT16; >> #else >> typedef int16_t INT16; >> #endif >> >> However, swig does not know _MSC_VER so I have to pass -D_MSC_VER >> explicitly from command line when msvc is used. (This is of course not >> swig's fault). >> >> 2. When I use %include "stdint.i", stdint.h is always included in the >> generated _wrap file. Because msvc does not define this header file. I >> have to use >> #ifndef _MSC_VER >> %include "stdint.i" >> #endif >> to get around this. >> >> The problem is that the generated _wrap files are different >> with/without -D_MSC_VER so I can not distribute a single _wrap file >> with my source distribution (so that users do not have to install swig >> to compile the python module). Is there any trick I can use to fix >> this? I guess I can accept something like >> %ifndef _WIN32 >> %include "stdint.i" >> %endif >> by forcing users to use msvc under windows. >> >> Many thanks in advance >> Bo > > You could just copy the contents of stdint.i (can be found somewhere in > your swig library) and paste/%include them in your wrapper file. Then > modify them as necessary (for example doing #ifndef _WIN32 %{ #include > "stdint.h %} #endif or somethign along the lines of that. > Alternatively, use the freely available portable stdint.h implementations. There are two mentioned at the bottom of this page: http://en.wikipedia.org/wiki/Stdint.h William |