[Python-Dev] use of #pragma GCC system_header to suppress _XOPEN_SOURCE warnings

"Martin v. Löwis" martin at v.loewis.de
Thu Aug 5 23:40:56 CEST 2004


Skip Montanaro wrote:
> At work the goal for our C++ build environment is "no warnings with gcc
> -Wall".  We are not there yet (and thankfully I am not a participant in that
> particular holy grail), but those involved in that effort encountered a
> warning the other day generated because _XOPEN_SOURCE is defined in
> pyconfig.h.  Unfortunately GCC also defines it, so a "macro redefined"
> warning is emitted when compiling with GCC and including Python.h.

That is not true. GCC does not define that macro, on any platform.

Some system header may define it, though. I believe this is a bug in the
system - the macro *should* be defined in the application. What system
are you referring to, and where does that define _XOPEN_SOURCE? Is that
definition conditional?

> Perhaps adding
> 
>     #pragma GCC system_header
> 
> to pyconfig.h.in would be acceptable though.

I'd prefer to solve the problem properly. If the system defines
something, and we define it differently, this *is* a problem, and
deserves a warning. We should find out why that is, and what
can be done about. Perhaps we should not define _XOPEN_SOURCE
on that platform until the vendor fixes the platform bug, or
we should aim at defining it the same way the vendor does.

Silencing errors is a risky thing.

Regards,
Martin


More information about the Python-Dev mailing list