XOPEN, POSIX and BSD defines in C vs. C++ code

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

 



Hi,

I ran into a rather interesting issue today.  I noticed that if I run
(with GCC 12.1)

gcc -x c -std=c17 -dM -E foo.c

where foo.c is simply

#include <features.h>

I don't get any of the XOPEN, POSIX or BSD defines that features.h would
typically
set based on -D options passed to the compiler.

However, if I run

gcc -x c++ -std=c++17 -dM -E foo.c

I get definitions like

#define _XOPEN_SOURCE 700.

I find this curious - I thought compilers were supposed to be OS standards
agnostic
(but obviously not language standards agnostic).

I am using a glibc 2.17 system, if that makes any difference.  I don't see
anything in
features.h that would indicate _XOPEN_SOURCE should be defined if the
compiler
is a C++ compiler conforming to the C++17 standard (for instance).

Any ideas as to what is going on here?  Is this expected behavior, as in
something in
the C++ standard I am unaware of, or is it a bug?

Thanks,

Tom



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux