I'm using Young's book on mixing C++ and Motif. In it, he says to use
XtGetSubresourc es() to be able to configure member data using the X
resource database. When I try this, based on Young's example,
class MyComponent: public UIComponent
{
...
private:
unsigned char _orientation
static XtResource _customResource s[];
...
}
XtResource MyComponent::_c ustomResources[]={
{
"orientatio n",
"Orientatio n",
XmROrientation,
sizeof(unsigned char),
XtOffsetOf(MyCo mponent,_orient ation),
XmRString,
(XtPointer)"HOR IZONTAL"
},{
...
}
};
I get compiler warnings about the above call to the XtOffsetOf()
macro.
% g++ -Wall -Wunused -W -ansi -pedantic -c MyComponent.C
MyComponent.C:1 16: warning: invalid offsetof from non-POD type
`class MyComponent'; use pointer to member instead
I understand the pointer to member syntax, but am not sure how to use
it here to appease the compiler. Is there a correct, portable, safe
way to do this?
Thanks,
Jim Williams
XtGetSubresourc es() to be able to configure member data using the X
resource database. When I try this, based on Young's example,
class MyComponent: public UIComponent
{
...
private:
unsigned char _orientation
static XtResource _customResource s[];
...
}
XtResource MyComponent::_c ustomResources[]={
{
"orientatio n",
"Orientatio n",
XmROrientation,
sizeof(unsigned char),
XtOffsetOf(MyCo mponent,_orient ation),
XmRString,
(XtPointer)"HOR IZONTAL"
},{
...
}
};
I get compiler warnings about the above call to the XtOffsetOf()
macro.
% g++ -Wall -Wunused -W -ansi -pedantic -c MyComponent.C
MyComponent.C:1 16: warning: invalid offsetof from non-POD type
`class MyComponent'; use pointer to member instead
I understand the pointer to member syntax, but am not sure how to use
it here to appease the compiler. Is there a correct, portable, safe
way to do this?
Thanks,
Jim Williams
Comment