This code generate 2 bugs:
#define BUG_TEST 0 typedef char * PCHAR; typedef struct { int I; int J; } A_OLD; typedef struct { int nI; int nJ; } A, *PA; typedef A xdata * PAx; A_OLD cAOld; #if BUG_TEST == 0 //Normal int l1 = (PCHAR)&(*(PA)(&cAOld)); //Get address of struct int l2 = ((PCHAR)&((*(PA)(&cAOld)).nI) - (PCHAR)&(*(PA)(&cAOld))); //Calc offset of member #elif BUG_TEST == 1 //Cann't initialize int l1 = (PCHAR)&(*(PAx)(&cAOld)); //Get address of struct #elif BUG_TEST == 2 //General fault C51 int l2 = (unsigned int)((PCHAR)&((*(PA)(&cAOld)).nI) - (PCHAR)&(*(PA)(&cAOld)));//Calc offset of member #endif
The problem will be fixed in the next version (7.07) that will come out in a few weeks. If you need a patch before that, send an email to: support.intl@keil.com.