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
Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> writes:
| On Wed, 2006-05-17 at 11:45 -0500, Roman Kononov wrote:
| > On 05/17/2006 11:12, Gabriel Dos Reis wrote:
| > > | They prevent from introducing safe C++ code.
| > >
|
| > Header.h and driver.c are old GCC code using all possible GCC extensions.
| > User.cpp is an attempt for C++ to co-exist in the Linux kernel. To make
| > driver.c and user.cpp, linked together, to work as they should, one needs to
| > do something with extern "C" struct spinlock_t {};. Currently, there is no
| > compiler help for the user compiling his user.cpp file to know about such
| > misbehavior.
|
| What I do not understand is why g++ assumes a C++ layout for the
| device_t (or spinlock_t) structure. extern "C" is supposedly meaning
| using the C layout whatever it is, no ?
No, 'extern "C"' is not meant to change the layout.
| Of course, then it is the use of such empty structures in g++ as members
| or bases that should be forbidden, and should trigger an error...
That does not make any sense to me.
| The current behaviour is a kind of a lie (unless I have skipped
| something in the C++ standard that explicitely allows for this
| interpretation) and error prone.
The current behaviour is standard mandated. I fail to see why it is
error prone and a kind of lie. If you ask me, it is quite the otehr
semantics that is error prone. The current g++ behaviour has been C++
semantics since the dark ages. GNU C decided to deviate from it.
-- Gaby