public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom Kacvinsky <tkacvins@gmail.com>
To: gcc-help <gcc-help@gcc.gnu.org>
Subject: XOPEN, POSIX and BSD defines in C vs. C++ code
Date: Wed, 7 Dec 2022 18:12:01 -0500	[thread overview]
Message-ID: <CAG_eJLcjPNVZyoH1c4hiKEWTVGNHWW+H4=9sZhwbTZ_Tesm-Vw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 927 bytes --]

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

             reply	other threads:[~2022-12-07 23:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 23:12 Tom Kacvinsky [this message]
2022-12-08  0:38 ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAG_eJLcjPNVZyoH1c4hiKEWTVGNHWW+H4=9sZhwbTZ_Tesm-Vw@mail.gmail.com' \
    --to=tkacvins@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).