cbindgen icon indicating copy to clipboard operation
cbindgen copied to clipboard

Generate flexible array members the c99 way instead of the GNU way

Open serge-sans-paille opened this issue 1 year ago • 2 comments

There a re three ways to express flexible array members:

  1. char fam[0];

  2. char fam[1];

  3. char fam[];

  4. is the only standard way (in c99, but supported in c++ as an extension), the other two are GNU syntax (still supported in clang though).

Let's generate the standard syntax by default, while leaving it possible to use 1. through struct.gnu_flexible_array_members

Cython only supports the 1. mode.

serge-sans-paille avatar Aug 15 '24 13:08 serge-sans-paille

@emilio even if that change is correct from a compiler point of view, it would actually break mozilla code if gnu behavior is of by default because the firefox codebase is making an optimistic use of flexible array members. I guess it's still good to merge this, but with gnu behavior on by default. What do you think?

serge-sans-paille avatar Aug 16 '24 17:08 serge-sans-paille

@emilio even if that change is correct from a compiler point of view, it would actually break mozilla code if gnu behavior is of by default because the firefox codebase is making an optimistic use of flexible array members.

Can you elaborate? Do you have an example?

emilio avatar Oct 27 '24 22:10 emilio