* [Fwd: non-POD error]
@ 2003-01-10 4:06 Chris Croswhite
2003-01-10 15:33 ` Gabriel Dos Reis
0 siblings, 1 reply; 2+ messages in thread
From: Chris Croswhite @ 2003-01-10 4:06 UTC (permalink / raw)
To: gcc
Forgot to mention the system:
gcc 3.2.1
Linux 2.4.18
x86
Error does not appear in gcc2.95.3 or 3.1
Could someone explain to me why I am seeing this error on the following
code:
warning: invalid offsetof from non-POD type `struct
endpoint_net_struct'; use pointer to member instead
Test case:
#include <stdio.h>
#include <linux/stddef.h>
class Myclass {
int _val;
};
struct foo_struct {
void *bar;
Myclass a;
};
int main(void)
{
printf("offset is %d\n", offsetof(struct foo_struct, bar));
}
If I remove the reference to the class, then I do not get this warning.
Is there a correct way to avoid this?
TIA,
Chris
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Fwd: non-POD error]
2003-01-10 4:06 [Fwd: non-POD error] Chris Croswhite
@ 2003-01-10 15:33 ` Gabriel Dos Reis
0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Dos Reis @ 2003-01-10 15:33 UTC (permalink / raw)
To: ccroswhite; +Cc: gcc
"Chris Croswhite" <ccroswhite@get2chip.com> writes:
| Could someone explain to me why I am seeing this error on the following
| code:
|
| warning: invalid offsetof from non-POD type `struct
| endpoint_net_struct'; use pointer to member instead
|
| Test case:
|
| #include <stdio.h>
| #include <linux/stddef.h>
|
| class Myclass {
| int _val;
| };
Saying class is equivalent to saying "struct" with making the default
access be private. Therefore the above declares Myclass as having a
private data member named _val. Therefore it is not a POD type, since
a POD cannot have a private data member.
[...]
| If I remove the reference to the class, then I do not get this warning.
| Is there a correct way to avoid this?
You probably wanted to say "struct Myclass" and not "class Myclass".
-- Gaby
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-01-10 10:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-10 4:06 [Fwd: non-POD error] Chris Croswhite
2003-01-10 15:33 ` Gabriel Dos Reis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).