[PATCH] D139266: Headers: tweak inclusion condition for stdatomic.h

Saleem Abdulrasool via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 6 09:34:50 PST 2022


compnerd added inline comments.


================
Comment at: clang/lib/Headers/stdatomic.h:21
+#if __STDC_HOSTED__ && __has_include_next(<stdatomic.h>)                        \
+    && !(defined(_MSC_VER) && __cplusplus-0 < 202002l)
 # include_next <stdatomic.h>
----------------
Mordante wrote:
> Is `__cplusplus-0` intentional? If so please add some comments how this differs from `__cplusplus`.
> Since this is a C header we should test whether the macro exists before querying its value.
Yes, that is intentional.  The `-0` is a trick!  That avoids the need to check for the definition, because it will be evaluated to as the value of `__cplusplus` or be `0` due to the expansion to CPP rules and `-0`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139266/new/

https://reviews.llvm.org/D139266



More information about the cfe-commits mailing list