pragma pack and inheritance

M

Mike Margerum

I seem to be running into an issue where I am deriving a new class from
a struct with a different alignemnt via the pragma pack


#pragma pack(1)
typedef struct
{
unsigned short a;
unsigned int b;
} MyBase;
#pragma pack()

class CDerived : public MyBase
{
public:
unsigned short c;
void SetData(unsigned int& u)
{
u = 123;
}
};



If i instantiate a CDerived class and call the SetData method with the b
attribute, i get a data abort in the debugger.

CDerived d;
d.SetData(b);

Why doesnt this work? I am running visual studio 2005 and am targeting
pocket pc 2003 SDK
 
M

Mike Margerum

sorry wrong group. i posted to the evc forum. it's only happening when
targeting the ppc2003 sdk in vc 2005
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top