This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SWIG options not being followed in all cases
Type: Stage:
Components: Distutils Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: epcylon, georg.brandl
Priority: normal Keywords:

Created on 2007-04-24 08:49 by epcylon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
swig_target.patch epcylon, 2007-04-24 08:49 Patch to check extension aswell when determining target_ext
Messages (2)
msg31872 - (view) Author: Morten Lied Johansen (epcylon) Date: 2007-04-24 08:49
I guess this is an undocumented feature, so maybe I shouldn't complain (but the patch to the docs has been in the patch tracker waiting to go in since 2004 it seems).

Default for SWIG is to produce C code, in a file called xxx_wrap.c. If you want C++, you need to specify the -c++ option (in which case you would normally want a file called xxx_wrap.cpp).


You can specify this option in two ways, either on the commandline, like so:

python setup.py build_ext --swig-opts="-c++"

or as an option to your Extention module in setup.py like so:
...
ext_modules = [Extension("_xxx", ["xxx.i","xxx.cpp"], swig_opts=["-c++"])]
...


The latter is much preferable, as it doesn't mean you have to remember to specify the option on the commandline all the time.

When specifying on the commandline, the -c++ is taken into account for creating the name of the output, and you get a file called xxx_wrap.cpp. Specifying the option in setup.py however, is not taken into account, and you get a file called xxx_wrap.c, which contains C++ code and generally doesn't compile (since the compiler assumes it's pure C).

I've attached a simple patch that seems to solve the problem.

msg31873 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-04-24 15:27
Thanks for the report, fixed in rev. 54941, 54942 (2.5).
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44890
2007-04-24 08:49:02epcyloncreate