H
Hiroki Horiuchi
Hello.
I wrote a program, but g++ warns
a.c:11: warning: invalid access to non-static data member `A::y' of NULL object
a.c:11: warning: (perhaps the `offsetof' macro was used incorrectly)
The program is like below.
class A
{
private:
int x;
int y;
public:
static unsigned int const y_offset;
};
unsigned int const A::y_offset = (
reinterpret_cast<char *>(&static_cast<A *>(0)->y)
-
static_cast<char *>(0)
);
I want to define a constant like A::y_offset with g++ without warnings.
Is it possible?
Thank you in advance.
//Hiroki Horiuchi
I wrote a program, but g++ warns
a.c:11: warning: invalid access to non-static data member `A::y' of NULL object
a.c:11: warning: (perhaps the `offsetof' macro was used incorrectly)
The program is like below.
class A
{
private:
int x;
int y;
public:
static unsigned int const y_offset;
};
unsigned int const A::y_offset = (
reinterpret_cast<char *>(&static_cast<A *>(0)->y)
-
static_cast<char *>(0)
);
I want to define a constant like A::y_offset with g++ without warnings.
Is it possible?
Thank you in advance.
//Hiroki Horiuchi