This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] warning about empty extern "C" structures


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*/
  };

Roman


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]