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

C51bugs

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

Parents Reply Children
No data