This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
invalid offsetof from non-POD type
- From: "Chris Croswhite" <ccroswhite at get2chip dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Thu, 9 Jan 2003 19:59:51 -0800 (PST)
- Subject: invalid offsetof from non-POD type
- Reply-to: ccroswhite at get2chip dot com
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