distutils & and C++ extentions

Jesper Olsen jolsen at mailme.dk
Thu Jan 17 13:43:44 EST 2002


Distutils is a great tool for making python C-extentions.

Has anyone used it for producing C++ extentions?

C++ functions called through python must be compiled with "C linkage"
- that is they need to be declared 'extern "C"' in C++ notation.

My problem is that the distutils module chooses to compile my
c++ code with the gcc C-compiler, and thus it generates an
error message when it encounters the c++ notation 'extern "C"'.

How can I specify that a source file is implemented in C++ and not C?
(.cc extention is not enough on my linux machine).

I get the impression that most extentions are written in C.
C is more portable than C++ of course, but is that the only reason?

Cheers
Jesper



More information about the Python-list mailing list