This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with alignment of variable in C++ Class

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.

Parents Reply Children
No data