We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm using uVision4 and C++ with LPC2478
class test { public: char s8; //placed at 0x4002C750 void* cp1; //placed at 0x4002C754 void* cp2; //placed at 0x4002C758 void* cp3; //placed at 0x4002C75C void* cp4; //placed at 0x4002C760 }
works
so i changed an Array
class test { public: char s8; //placed at 0x4002C750 void* cp1[4]; //placed at 0x4002C752 !! }
so this didn't not working it makes dabt error if I used cpl[0] the pointer is only the lower Bits.
after searching 2 days for the reason, I found the Compiler placed it to an unaligned address.
why? and how can i fixed it.
One more thing - are you sure that your C++ object is properly aligned? Remember that a C++ class can have own hidden member data.
In case the compiler have consumed 2 bytes internally before the s8 variable, then the pointer array does start n*4 bytes into the object.