[Python-Dev] #ifdef __cplusplus?

Christian Heimes lists at cheimes.de
Fri Jan 2 05:05:11 CET 2009


Alexander Belopolsky schrieb:
> The relevant revision is r45330:
> <http://svn.python.org/view?rev=45330&view=rev>.
> 
> """
> Author:	anthony.baxter
> Date:	Thu Apr 13 02:06:09 2006 UTC (2 years, 8 months ago)
> Log Message:
> spread the extern "C" { } magic pixie dust around. Python itself builds now
> using a C++ compiler. Still lots and lots of errors in the modules built by
> setup.py, and a bunch of warnings from g++ in the core.
> """
> 
> Wrapping code inside .c files in  extern "C" { }  strikes me as a lazy
> solution.  It is likely that g++ warnings that were silenced by that
> change were indicative of either functions not declared in headers
> missing "static" keyword or .c files not including relevant headers.
> 
> If OP has energy to investigate this issue further, it would be
> interesting to revert  r45330 and recompile python with CC=g++.

You might be interested in the bug report
http://bugs.python.org/issue4665. Skip pointed out that Python 2.6 no
longer compiles with a C++ compiler due to missing casts. C++ is more
restrict when it comes to implicit casts from (amongst others) void
pointers.

Martin is against the necessary changes. I don't really care about it.
If somebody wants to tackle the issue I'm fine with sprinkling some type
casts over the code.

This topic is slightly related to small feature request in
http://bugs.python.org/issue4558. It adds a configure option
--with-stdc89 and adds some small fixes to various modules. The
--with-stdc89 is dedicated for our build bots. In the past non ANSI C89
conform pieces of code like 'inline' or '// C++' comments were
committed. The --with-stdc89 options adds a canonical way to detect such
errors at compile time.

Christian



More information about the Python-Dev mailing list