Examples\pde build problem, SWIG with NT and VC++
Mike Haspert
mike_haspert at credence.com
Mon Jun 18 12:50:18 EDT 2001
I am new to Python and SWIG. I managed to build the pde example in the SWIG
doc using VC++6.0, Python2.1, and SWIG1.1, but only after commenting out
extern "C" around #include python.h. in pde_wrap.cpp (and changing the extension
of the output file from .c to .cpp). Everything seems to work but I am not confident
I've done the right thing and suspect that I'm doing a newbie thing like using/not using
some option incorrectly.
Should I expect the wrapper file to need tweaks or not?
Has anyone working with SWIG and VC++ built this example?
If so, did you hit this problem, and do you have a better idea than tweaking the
wrapper?
Thanks in advance for any help.
-mlh
///////////////////details///////////////////////////////////////
I ran SWIG like this and got no error messages:
swig -python -c++ -shadow pde.i
The code I had to comment out in the wrapper file was as follows:
//#ifdef __cplusplus
//extern "C" {
//#endif
#include "Python.h"
//#ifdef __cplusplus
//}
//#endif
The compile errors I got before commenting it out were consistent, math.h gets sucked
in when including python.h and it has template code that doesn't get preprocessed away:
pde_wrap.cpp
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\math.h(514) : error C2894:
templates cannot be declared to have 'C' linkage
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(700) : error C2733:
second C linkage of overloaded function 'wmemchr' not allowed
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(699) : see
declaration of 'wmemchr'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(702) : error C2733:
second C linkage of overloaded function 'wcschr' not allowed
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(701) : see
declaration of 'wcschr'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(704) : error C2733:
second C linkage of overloaded function 'wcspbrk' not allowed
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(703) : see
declaration of 'wcspbrk'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(706) : error C2733:
second C linkage of overloaded function 'wcsrchr' not allowed
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(705) : see
declaration of 'wcsrchr'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(708) : error C2733:
second C linkage of overloaded function 'wcsstr' not allowed
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(707) : see
declaration of 'wcsstr'
Error executing cl.exe.
The #defines that lead to the offending code being included seem correct to me.
More information about the Python-list
mailing list