C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: Undefining a compiler 's predefined macro
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2020-03-22 09:08:55


On Sun, 22 Mar 2020 at 16:05, Edward Diener via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> On 3/22/2020 9:38 AM, Ville Voutilainen via Std-Discussion wrote:
> > On Sun, 22 Mar 2020 at 14:32, Edward Diener via Std-Discussion
> > <std-discussion_at_[hidden]> wrote:
> >>>> But if a compiler has a documented predefined macro which is not in the
> >>>> subclause is it valid C++ to undefine that macro, and must a C++
> >>>> standard conforming compiler allow it ?
> >>>
> >>> No, and no. Do you have an example of such a macro? Do you think it's
> >>> valid to name it
> >>> in your program, considering http://eel.is/c++draft/lex.name#3 ?
> >>
> >> I had no intention of naming it in my program, other than undefining it.
> >> I actually have a good reason for undefining a compiler predefined macro
> >> in the code base in which I am working. However your link suggests that
> >> it is not valid C++ to undefine a compiler implemented predefined macro
> >> which starts with a double underscore. But I do find the wording of:
> >>
> >> "In addition, some identifiers are reserved for use by C++
> >> implementations and shall not be used otherwise; no diagnostic is required."
> >>
> >> a bit vague in that "and shall not be used otherwise" is not given any
> >> precise meaning. Is undefining a predefined macro "using" the macro ?
> >> Probably, but the imprecise meaning of the term "used otherwise" can
> >> certainly be improved in that note.
> >
> > The "shall not be used otherwise" certainly covers any use that would
> > change the meaning
> > of the token - like undefining it. Or using it as a name in your own
> > definition. So, you can actually
> > name it, as long as that name means what the implementation defined it
> > to mean. Any change
> > to that meaning is IFNDR.
>
> What do you mean by "name it" ? In my particular case of a compiler
> predefined macro starting with a double underscore you can not do
> anything to "name it" that I can see.

As in #if __whatever_name

If the implementation intended that to be a correct use, then it's a
correct use.


STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups