>Number: 60389
>Category: standards
>Synopsis: sys/featuretest.h: _XOPEN_SOURCE=520 fails to imply _POSIX_C_SOURCE=199506L
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: standards-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jun 30 15:00:00 +0000 2026
>Originator: Taylor R Campbell
>Release: current, 11, 10, 9, ...
>Organization:
The X/Open BSD Foundation, Inc.
>Environment:
>Description:
According to Networking Services (XNS), Issue 5.2,
_XOPEN_SOURCE>=500, not just _XOPEN_SOURCE=500, should imply
_POSIX_C_SOURCE=199506L:
> [I]f _XOPEN_SOURCE is set greater than or equal to 500 and
> _POSIX_SOURCE is defined, or _POSIX_C_SOURCE is set greater
> than zero and less than or equal to 199506L, the behavior is
> the same as if only _XOPEN_SOURCE is defined and set greater
> than or equal to 500.
https://pubs.opengroup.org/onlinepubs/009619199/chap1.htm#tagcjh_02_03
But we only define _POSIX_C_SOURCE if _XOPEN_SOURCE=500
exactly, not >=500.
148 #elif (_XOPEN_SOURCE - 0) == 500
149 #define _POSIX_C_SOURCE 199506L
150 #endif
https://nxr.netbsd.org/xref/src/sys/sys/featuretest.h?r=1.13#139
>How-To-Repeat:
#define _XOPEN_SOURCE 520
#include <sys/featuretest.h>
#ifndef _POSIX_C_SOURCE
#error "fail"
#endif
>Fix:
Change == to >=.
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.