This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] warning about empty extern "C" structures
Roman Kononov <kononov195-far@yahoo.com> writes:
| > But not in GNU C:
| > GCC permits a C structure to have no members:
| > struct empty {
| > };
| > The structure will have size zero. In C++, empty structures are
| > part
| > of the language. G++ treats empty structures as if they had a single
| > member of type `char'.
| Linux kernel, all written in C, has many empty structures.
you mean in GNU C. That is understood.
empty structures have been part of C++ since the dark ages, and the
behaviour of g++ matches the semantics of the language. Notice that
g++ also implements the empty-base optimziations -- but those can be
(GNU) C anymore.
| They prevent from introducing safe C++ code.
I don't understand that comment.
-- Gaby