-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Open
Labels
buildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Consider the following simple program:
#define _XOPEN_SOURCE 900
#include <Python.h>
int main() { }now try to compile it:
$ 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?
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
buildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error