[libcxx-commits] [libcxx] [libc++] Enable availability based on the compiler instead of __has_extension (PR #84065)
Aaron Ballman via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 6 07:52:19 PST 2024
AaronBallman wrote:
> > That means that as it stands, libc++ is not compatible at all with `-pedantic-errors`, since it uses a good number of compiler extensions (and really there’s no way it could go without using compiler extensions).
>
> It's not that `-pedantic-errors` disables extensions, it disables `__has_extension` properly reporting extensions.
No, it kind of does disable extensions, which is *why* `__has_extension` returns `false`. When you specify `-pedantic-errors`, you are saying "any use of an extension is an error" so extensions really aren't available for you. The idea being:
```
#if __has_extension(foo)
#define FOO use_the_extension
#else
#define FOO use_the_fallback
#endif
```
should work. If `__has_extension` returns `true` with `-pedantic-errors`, then you'll use the extension and get compile errors as a result instead of using the fallback path.
https://github.com/llvm/llvm-project/pull/84065
More information about the libcxx-commits
mailing list