Re: Use of feature test macros

Roland Illig <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
Am 03.11.2024 um 00:52 schrieb Robert Elz:
>     Date:        Sat, 2 Nov 2024 22:36:10 +0100
>     From:        Roland Illig <[email protected]>
>
>   | Is the "- 0" in the first expression really necessary? If so, for which
>   | cases?
>
> When _POSIX_C_SOURCE is undefined (or defined to nothing).
> That is the standard idiom for testing all of these feature macros.

When _POSIX_C_SOURCE (or any other identifier) is undefined, the
preprocessor replaces it with 0. This has been spelled out in the C
standards since C90, for example in C23 6.10.2p13, and I thought it
would be common knowledge, that's why I didn't mention it in my original
questions.

From what I'm reading out of <sys/featuretest.h>, _POSIX_C_SOURCE is not
defined to empty for any version of POSIX, thus making the "- 0" part
superfluous. That part may be necessary for _XOPEN_SOURCE, but not for
_POSIX_C_SOURCE.

Roland
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.