This is the mail archive of the gcc@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]

invalid offsetof from non-POD type


Hello all,

Perhaps someone could give me had with understanding this error:
"foo.c:15: warning: invalid offsetof from non-POD type `struct foo_struct';
use pointer to member instead"

Here is the simplest test:

#include <stdio.h>
#include <linux/stddef.h>

class Myclass {
          int _val;
};

struct foo_struct {
          Myclass a;
          void *bar;
};

int main(void)
{
          printf("offset is %d\n", offsetof(struct foo_struct, bar));
}


The class within the struct is causing offsetof warning.  Could someone
describe why this is a warning and if this produces invalid code.  If this
is correect code, is there a way to turn off this warning?

TIA,
Chris





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