[clang] [Clang][Sema]: Allow flexible arrays in unions and alone in structs (PR #84428)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 12 06:14:45 PDT 2024


erichkeane wrote:

> > There are currently over 200 separate unions using the work-around.
> 
> Specifically, this is what Linux uses for getting C99 flexible arrays in unions and alone in structs:
> 
> ```
> #define DECLARE_FLEX_ARRAY(TYPE, NAME)        \
>         struct { \
>                 struct { } __empty_ ## NAME; \
>                 TYPE NAME[]; \
>         }
> ```
> 
> The conversion (over 6 years) from the "struct hack" to C99 flexible arrays is complete, except for this wart.

That one ends up not being a problem, but presumably you are wanting to change that top-level 'struct' to be a 'union'?  What is the problem with making it `TYPE NAME[0];` ?

https://github.com/llvm/llvm-project/pull/84428


More information about the cfe-commits mailing list