Can Python be compiled by a C++ compiler ?

David M. Cooke cookedm+news at physics.mcmaster.ca
Wed May 12 12:00:29 EDT 2004


At some point, Helmut Jarausch <jarausch at skynet.be> wrote:

> Hi,
>
> having read http://www.python.org/doc/current/ext/ext.html by Guido
> van Rossum and Fred Drake,
> I got the impression I should compile Python with g++ since section 1.11
> indicates that otherwise the constructor of a global or static object
> (of an extension in C++) won't be called.
>
> Now trying to build Python (CVS version) with g++ fails. E.g., one
> problem is in Parser/pgen.c line 364 with a typical C-like confusion
> of types and variables when it declares
>
> ss_arc *ss_arc
> where ss_arc is defined by a previous typedef. A C++ compiler won't
> accept this.
>
> Do I miss something?

Yes. Just specify the C++ compiler to the configure script with the
--with-cxx option. My guess it already does this automatically, and
you're just making more work for yourself.

Everything will be compiled with the C compiler (gcc), but will be
linked by the C++ compiler. This assures that the appropiate run-time
stuff needed for C++ extensions is linked in (or something like that),
without actually having to rewrite Python in C++.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca



More information about the Python-list mailing list