Hello, Depending on the control #pragma pack(x), the result of the compilation is different. In C++, Here's the problem, but it is more difficult without picture:
With #pragma pack(2), the result is Ok.
TNetCv::TNetCv(void) { DCvPtrNetPtcl = Nil; .... Compiling give: 0x0801A95C 2000 MOVS r0,#0x00 0x0801A95E F8C40026 STR r0,[r4,#0x26] void TNetCvCOM::CvDoWhenNetEvent(ENUMNETEVENT TheCvEvent) { TNetCv::CvDoWhenNetEvent(TheCvEvent); // INHERITED switch(TheCvEvent) { case eNetEventRun: if (DCvPtrNetPtcl != Nil) DCvPtrNetPtcl->PtclDoWhenNetEvent(TheCvEvent); break; } } Compiling give: 97: if (DCvPtrNetPtcl != Nil) DCvPtrNetPtcl->PtclDoWhenNetEvent(TheCvEvent); 0x0801F782 F8D40026 LDR r0,[r4,#0x26] 0x0801F786 B128 CBZ r0,0x0801F794 0x0801F788 F8D40026 LDR r0,[r4,#0x26] 0x0801F78C 6801 LDR r1,[r0,#0x00] 0x0801F78E 6A0A LDR r2,[r1,#0x20] 0x0801F790 4629 MOV r1,r5 0x0801F792 4790 BLX r2
In both examples the offset of the pointer "DCvPtrNetPtcl" is 0x26
With #pragma pack(4), the result is Bad.
TNetCv::TNetCv(void) { DCvPtrNetPtcl = Nil; .... Compiling give: 0x0801A95C 2000 MOVS r0,#0x00 0x0801A95E F8C40026 STR r0,[r4,#0x26] void TNetCvCOM::CvDoWhenNetEvent(ENUMNETEVENT TheCvEvent) { TNetCv::CvDoWhenNetEvent(TheCvEvent); // INHERITED switch(TheCvEvent) { case eNetEventRun: if (DCvPtrNetPtcl != Nil) DCvPtrNetPtcl->PtclDoWhenNetEvent(TheCvEvent); break; } } Compiling give: 97: if (DCvPtrNetPtcl != Nil) DCvPtrNetPtcl->PtclDoWhenNetEvent(TheCvEvent); 0x0801F3FE 6AA0 LDR r0,[r4,#0x28] 0x0801F400 B120 CBZ r0,0x0801F40C 0x0801F402 6AA0 LDR r0,[r4,#0x28] 0x0801F404 6801 LDR r1,[r0,#0x00] 0x0801F406 6A0A LDR r2,[r1,#0x20] 0x0801F408 4629 MOV r1,r5 0x0801F40A 4790 BLX r2
Without changing a line of code Now, in the initialization is always offset 0x26, but in the second function the offset is 0x28. The result is an exception "UsageFault"
thank you for your help
Jean-François