This is the mail archive of the gcc-help@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:
"invalid offsetof from non-POD type; 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 a warning.  Could someone
describe why this is a warning and this produces invalid code.  If this is
correect, 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]