MSVC requires that C++23 be available (_HAS_CXX23) else the entire
content is elided. Conditionalise the inclusion properly so that C/C++
code using stdatomic.h for memory_order_* constants are able to do
so without changing the C++ standard. This repairs builds of Swift and
libdispatch after ba49d39b20cc5358da28af2ac82bd336028780bc.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for the patch!
clang/lib/Headers/stdatomic.h | ||
---|---|---|
21 | Is __cplusplus-0 intentional? If so please add some comments how this differs from __cplusplus. |
clang/lib/Headers/stdatomic.h | ||
---|---|---|
21 | 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. |
Thanks for working on this! The changes LGTM. I've been trying to figure out if there's a way we can add test coverage for this change, but I'm really not coming up with much. However, the changes definitely should have a release note.
clang/lib/Headers/stdatomic.h | ||
---|---|---|
23 | 202002l -> 202002L to make it easier on people's eyeballs. |
LGTM after addressing @aaron.ballman's comments.
clang/lib/Headers/stdatomic.h | ||
---|---|---|
21 | Ah yes of course. I really prefer the current version without the trick. |
We think this is incorrect, see comments here: https://boringssl-review.googlesource.com/c/boringssl/+/55845/3/crypto/refcount_c11.c#18
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.