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
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Roman Kononov <kononov195-far at yahoo dot com>
- Cc: Andrew Pinski <pinskia at physics dot uc dot edu>, Mark Mitchell <mark at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: 20 Jun 2006 16:52:15 +0200
- Subject: Re: [C++ PATCH] warning about empty extern "C" structures
- References: <e4fce1$nrb$1@sea.gmane.org> <200605171508.k4HF8niT008668@greed.delorie.com> <446B4279.8010200@yahoo.com> <m3lkt039wi.fsf@uniton.integrable-solutions.net> <20060517162603.GA7859@nevyn.them.org> <m3sln81u6q.fsf@uniton.integrable-solutions.net> <20060517173419.GA9583@nevyn.them.org> <m3zmhgzfl4.fsf@uniton.integrable-solutions.net> <20060517184335.GA11683@nevyn.them.org> <446B70E9.2010505@codesourcery.com> <446B9B47.3060101@yahoo.com> <446B9E1A.9000504@codesourcery.com> <446BDCDB.4010405@yahoo.com> <C36CC8EC-3792-44C1-908E-4D3B0A7FDF7C@physics.uc.edu> <446BE3F2.50406@yahoo.com> <8D8F830E-9D51-4977-8FE2-A9AD649F2713@physics.uc.edu> <446BE9CD.3070806@yahoo.com>
Roman Kononov <kononov195-far@yahoo.com> writes:
| On 05/17/2006 22:08, Andrew Pinski wrote:
| > On May 17, 2006, at 8:03 PM, Roman Kononov wrote:
| >
| >>
| >> extern "C" {
| >> static inline int foo(int socket) {
| >> struct empty_t {};
| >> struct network_message_t {
| >> empty_t foo;
| >> int stuff;
| >> } msg;
| >> msg.stuff=0;
| >> return send(socket,&msg,sizeof(msg));
| >> }
| >> }
| >>
| >> We would like foo() to send same message from C++ and C code.
| > That is just bogus. Why have an empty struct in there in the first
| > place.
| > The only place empty structs come handy is where they don't store data
| > and are needed to pass around as pointers like a lock (though I don't
| > think that is a good use anyways).
|
| It is not bogus. Instead of just
|
| struct empty_t {};
|
| think about this:
|
| struct empty_t {
| #ifdef MSG_DEBUG
| int debug;
| #endif
| #ifdef MAGIC
| long magic;
| #endif
| /*and so on for few pages*/
| };
the point is?
-- Gaby