bug-gnulib
[Top][All Lists]
Advanced

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

Re: stdbool: Fix compilation error in C++ mode with MSVC 14


From: Bruno Haible
Subject: Re: stdbool: Fix compilation error in C++ mode with MSVC 14
Date: Sun, 04 Sep 2022 23:50:44 +0200

Paul Eggert wrote:
> > +# if !defined _MSC_VER
> > +#  define false false
> > +#  define true true
> > +# endif
> 
> How about using "#ifndef true" instead?

This will not work, as 'true' and 'false' are keywords, not macros, in C++ mode,
with this compiler.

> That will be more portable in 
> the presence of other platforms with this portability issue.

The portability issue is that one of the MSVC headers does basically
  #ifdef __cplusplus
  # if defined false || defined true || defined bool || ...
  #  error "..."
  # endif
  #endif

For the combination of clang with MSVC header files, clang defines _MSC_VER,
therefore the workaround should also be effective in this case.

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]