Use in practice and use in documentation don't always align but it seems you're agreeing that requiring GNU macros to use a Linux specific header is invalid.

Jon

On Wed, 24 Apr 2024, 08:55 Jeffrey Walton, <noloader@gmail.com> wrote:


On Wed, Apr 24, 2024 at 3:40 AM Jon Chesterfield <jonathanchesterfield@gmail.com> wrote:
Re testing GNUC,

I'm not sure the macro means "targeting Linux", and it seems totally legitimate that a C compiler which doesn't implement any GNU extensions would not define that macro. Musl is quite a likely choice for a non-gnu compiler that wants to compile code to run against the Linux kernel.

__GNUC__, __GNUC_MINOR__ and __GNUC_PATCHLEVEL__ only means the macros are defined by GNU compilers that use the C preprocessor. See <https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html>.

The macros don't mean "targeting Linux". They are also defined on OS X (Darwin) and Windows.

Jeff