[Python-Dev] #ifdef __cplusplus?
M.-A. Lemburg
mal at egenix.com
Fri Jan 2 16:43:57 CET 2009
On 2009-01-02 00:54, Nick Coghlan wrote:
> Ulrich Eckhardt wrote:
>> Hi!
>>
>> There are lots of files that are framed with an extern "C" stanza when
>> compiled under C++. Now, I appreciate that header files are made suitable for
>> use with C++ with that, but WTF are those doing in .c files???
>
> I believe it is to allow building the Python source as an embedded part
> of an external application that is built with a C++ compiler,
That's the reason, yes.
Mixing .c and .cpp files in a compiler call will not always cause
an implicit extern "C" to be used for the .c files. This causes problems
for cases where you rely on the naming of the exported functions, e.g.
for the module init function. C++ mangles all exported symbols. extern "C"
disables this.
AFAIR, early versions of MS VC++ used to compile everything as C++
file, regardless of the extension.
> even when
> that compiler isn't clever enough to realise that the 'extern "C"'
> should be implied by the '.c' file extension.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Jan 02 2009)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
More information about the Python-Dev
mailing list