tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Use of feature test macros



Am 03.11.2024 um 00:52 schrieb Robert Elz:
>     Date:        Sat, 2 Nov 2024 22:36:10 +0100
>     From:        Roland Illig <roland.illig%gmx.de@localhost>
>
>   | 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



Home | Main Index | Thread Index | Old Index