On Tue, Sep 12, 2023 at 07:22:24PM +0300, Alexey Dobriyan wrote: > __DECLARE_FLEX_ARRAY(T, member) macro expands to > > struct { > struct {} __empty_member; > T member[]; > }; > > which is subtly wrong in C++ because sizeof(struct{}) is 1 not 0, > changing UAPI structures layouts. Looking at this again just now, what about using a 0-length array instead of an anonymous struct? https://godbolt.org/z/rGaxPWjef Then we don't need an #ifdef at all... struct { int __empty_member[0]; T member[]; }; -Kees -- Kees Cook