C++ Logo

std-discussion

Advanced search

Re: Undefining a compiler 's predefined macro

From: Edward Diener <eldlistmailingz_at_[hidden]>
Date: Sun, 22 Mar 2020 09:58:36 -0400
On 3/22/2020 9:34 AM, Thiago Macieira via Std-Discussion wrote:
> On Sunday, 22 March 2020 09:32:08 -03 Edward Diener via Std-Discussion wrote:
>> 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:
>
> Can you tell us what that reason is?

Does the reason really matter ? I can assure you that the reason is a
good one along the lines of the codebase in which I am dealing, but if
it is not valid C++ to undefine a double underscore predefined macro
then it will not be done for the particular codebase, which seeks to be
as C++ standard compliant as possible.

The general reason, since you seem curious, is that the codebase has
many instances of testing the predefined macro for one-off workarounds
for the particular compiler, which was not C++ standard compliant in a
number of cases. But with some change in the compiler implementation,
which can be easily detected in general in a single place in the code,
the one-off workarounds are no longer needed. Rather than have to change
the codebase to do the same detection in all the other places where the
predefined macro is being used, so as not to do the prescribed
workaround for the compiler implementation, it would be much easier to
undefine the predefine macro when it is detected in the single place in
the code.

Received on 2020-03-22 09:01:32