[Python-Dev] Problems with definition of _POSIX_C_SOURCE
"Martin v. Löwis"
martin at v.loewis.de
Thu Mar 17 09:19:17 CET 2005
Jack Jansen wrote:
> The comment in pyconfig.h suggests that defining _POSIX_C_SOURCE may
> enable certain features, but the actual system headers appear to work
> the other way around: it seems that defining this will disable features
> that are not strict Posix.
> Does anyone know what the real meaning of this define is? Because if it
> is the former then Python is right, but if it is the latter Python
> really has no business defining it
As you can see from the formal definition that Tim gave you, both is
right: the macro causes system headers to provide the functions that
POSIX says they should provide, and remove functions that POSIX does
not mention, except when enabled through other feature selection macros.
> in general Python isn't 100%
> posix-compliant because it'll use all sorts of platform-dependent (and,
> thus, potentially non-posix-compliant) code...
Python is 100% POSIX compliant. It also uses extensions to POSIX on
platforms that provide them, but if these extensions are not available,
it falls back to just not using them.
So Python really uses "POSIX with extension". A careful operating system
developer will understand that this is a useful programming model, and
provide feature selection macros to enable features that go beyond
POSIX. That's why you can see various feature selection macros at
the beginning of configure.in.
In case you wonder why Python defines this in the first place: some
platforms really need the definition, or else they don't provide
the proper header contents (i.e. they fall back to ISO C for some
headers), most notably Tru64 and HP-UX. Other systems implement
different versions of the same API, e.g. Solaris, and defining
_POSIX_C_SOURCE makes these systems provide the POSIX version of the
API.
> This problem is currently stopping Python 2.4.1 to compile on this
> platform, so if anyone can provide any insight that would be very
> helpful...
Just define _THIS_PLATFORM_SOURCE. If there is no such define, complain
to the vendor of this platform, and ask Apple to provide such a macro.
If this falls on deaf ears, go to the block "Some systems cannot stand
_XOPEN_SOURCE being defined at all;" in configure.in and make another
entry. Make sure that entry:
- lists the precise reason for the entry (e.g. what
structure/type/function gets hidden that shouldn't be hidden)
- lists your name as the contact to ask for details
- is specific to the particular release of this platform, so
if future versions of this platform fix the bug, the work-around
of disabling _XOPEN_SOURCE and _POSIX_C_SOURCE can be removed
Regards,
Martin
More information about the Python-Dev
mailing list