On 2026-03-06 15:17, Nathan Chancellor wrote:
> On Thu, Mar 05, 2026 at 03:43:29PM -0800, H. Peter Anvin wrote:
>> Question: does clang allow this with __extension__, or only if the option is
>> on the command line? It would be desirable in the long run if both clang and
>
> It looks like only on the command line:
>
> https://godbolt.org/z/zrE766obe
>
>> gcc would allow this with __extension__, as that would be required to use it
>> in uapi headers (at least without some doable-but-nontrivial preprocessing,
>> which might be worthwhile to do anyway...)
>
> I agree that would be desirable but wouldn't that change how
> __extension__ works? As far as I can tell from reading GCC's
> documentation [1], __extension__ just supresses warnings from -pedantic
> and such, it does not actually enable a used extension if it conflicts
> with whatever -std= value is passed?
>
> [1]: https://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html
>
Maybe it does, but it's explicit purpose is to allow code to be compiled with
a -std= setting lower than the system libraries.
I was a little surprised to see that -std=c90 doesn't actually enforce C90
compatibility; even with -Wall -Wextra it requires -pedantic to issue
warnings; the same seems to apply to -std=c99 for at least some features that
were included in gnu* standards like anonymous structures and unions.
The latter is probably a particular indication about the desirability of this,
since the extension we are talking about is a relatively obvious extension of
the anonymous struct/union construct!
It is an incredibly useful thing in ABI headers, because it lets you avoid the
"copy/macro this entire structure definition into another."
-hpa