This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: including Python.h redefines _POSIX_C_SOURCE
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jhellan, loewis
Priority: normal Keywords:

Created on 2004-08-27 08:43 by jhellan, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg22234 - (view) Author: Jon Kåre Hellan (jhellan) Date: 2004-08-27 08:43
Consider this program:

#include <limits.h>
#include <Python.h>

int main (int arg, char **argv)
{
	return 0;
}

We compile it like this

cc -Wall -I/usr/include/python2.3 -c aa.c

And get

In file included from /usr/include/python2.3/Python.h:8,
                 from aa.c:3:
/usr/include/python2.3/pyconfig.h:853:1: warning:
"_POSIX_C_SOURCE" redefined
In file included from /usr/include/limits.h:26,
                 from
/usr/lib/gcc-lib/i486-linux/3.3.4/include/limits.h:122,
                 from
/usr/lib/gcc-lib/i486-linux/3.3.4/include/syslimits.h:7,
                 from
/usr/lib/gcc-lib/i486-linux/3.3.4/include/limits.h:11,
                 from aa.c:2:
/usr/include/features.h:171:1: warning: this is the
location of the previous definition

Python.h has redefind a symbol which got defined by
including 
limits.h. This is unfriendly to programs which embed
Python. 

I suspect that there are definitions in pyconfig.h
which are only
relevant when building the Python distribution. Such
definitions 
should not be exposed to embedders or builders of 3rd
party modules.

I can make the warning go away by including Python.h
first. But my application has its own config.h -
strange that Python's has to go
in front of it.
msg22235 - (view) Author: Jon Kåre Hellan (jhellan) Date: 2004-08-27 08:56
Logged In: YES 
user_id=268898

Sorry about the duplicate. That was my browser's "back" button.
Platform is Debian sid (soon to be sarge), and Python
version is 2.3.
msg22236 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-09-04 16:52
Logged In: YES 
user_id=21627

Your program is in error - it must not include limits.h
before including Python.h, see

http://docs.python.org/api/includes.html

The defines in Python.h *can* affect the code in the
extension module, e.g. they might affect the size of off_t.
Extensions which don't follow this rule may crash.
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40831
2004-08-27 08:43:44jhellancreate