You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pyconfig.h defines _XOPEN_SOURCE conditionally and unconditionally as well #144870
$ gcc -Wall -Werror $(pkg-config --libs --cflags python3) test.c
In file included from /usr/include/python3.14/Python.h:14,
from test.c:2:
/usr/include/python3.14/pyconfig.h:2043:9: error: ‘_XOPEN_SOURCE’ redefined [-Werror]
2043 | #define _XOPEN_SOURCE 700
| ^~~~~~~~~~~~~
test.c:1:9: note: this is the location of the previous definition
1 | #define _XOPEN_SOURCE 900
| ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
this is because pyconfig.h (included by Python.h) unconditionally defines both macros. What's curious is that there is already a conditional part regarding _XOPEN_SOURCE, but then it is later unconditionally defined with the same value. That seems odd.
Even with a locally configured build on the master branch, the structure is still the same:
$ ./configure --prefix=/usr \
--enable-shared \
--with-computed-gotos \
--enable-optimizations \
--with-lto \
--enable-ipv6 \
--with-system-expat \
--with-dbmliborder=gdbm:ndbm \
--with-system-libmpdec \
--enable-loadable-sqlite-extensions \
--without-ensurepip \
--with-tzpath=/usr/share/zoneinfo
[...]
$ grep -C1 _XOPEN_SOURCE pyconfig.h
to make mbstate_t available. */
#ifndef _XOPEN_SOURCE
# define _XOPEN_SOURCE 800
#endif
--
/* Define to the level of X/Open that your system supports */
#define _XOPEN_SOURCE 800
/* Define to activate Unix95-and-earlier features */
#define _XOPEN_SOURCE_EXTENDED 1
This will always trigger a macro redefinition warning if pyconfig.h (hence Python.h) is included where _XOPEN_SOURCE is defined with a value not equal to 800. Why is the file set up so?
Activity
pobrn commentedon Feb 16, 2026
As expected, this is already a well known thing: #61322
brianschubert commentedon Feb 16, 2026
@pobrn good find, I'll mark this as a duplicate then