[issue4805] Make python code compilable with a C++ compiler

Marc-Andre Lemburg report at bugs.python.org
Tue Jan 6 11:42:10 CET 2009


Marc-Andre Lemburg <mal at egenix.com> added the comment:

On 2009-01-05 22:06, Alexander Belopolsky wrote:
> Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
>> Given that you can build Python as library on Unix and as DLL on
>> Windows, there doesn't appear to be any need to actually be able
>> to build Python itself using a C++ compiler. Simply using the
>> header files and linking against those libraries should do the
>> trick in most cases.
> 
> So what is your position on the proposed patch?  Is it worthwhile to
> track down the remaining symbols that may be affected by removal of
> extern "C" from .c files?  What is your opinion on the original patch
> (c++-patch.diff) which restores C++ compilability but does not touch
> these declarations?
> 
> I think using C++ as a lint variant from time to time is a good
> exercise to catch some corner issues as I hope this patch
> demonstrates.  I don't think this should be a requirement on every
> submission, but once an effort is made to restore C++ compilability,
> such changes should be applied unless there are valid concerns against
> them.

I agree with using C++ compatibility as additional means of checking
for correctness of the code. The type casts you have added in the
patch should definitely make it into the trunk.

Making sure that all exported private symbols get a _Py prefix and
a declaration in the header files that adds a comment explaining their
private nature is also a good idea.

I'm not sure about removing the extern "C" declarations altogether.
We'd need further testing with non-G++ compilers to see whether we
still need them or not. With the above fixes, I doubt that we still
need them nowadays.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4805>
_______________________________________


More information about the Python-bugs-list mailing list