3 ms·
> Empty structs are supported in clang; I think it's a GCC extension to C. Indeed. See https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Empty-Structures.html http
by Someone 1y ago
> Empty structs are supported in clang; I think it's a GCC extension to C.
Indeed. See https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Empty-Structures.html https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Empty-Structur....
That page also says “In C++, empty structures are part of the language”, and “G++ treats empty structures as if they had a single member of type char”. I think that means the size of empty structs differs between GCC C and GCC C++.
- kragen 1y agoThanks! Yes, C++ requires all objects to have a nonzero size. In GCC these two variables get the same address; also true in clang with -O.