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

Need explination of these two decloration software lines

What do the following lines do? Generaly not specificaly.

What do the terms mean/and or do? 1) xdata * xdata mean? 2) s_pSIN = (MASTER_2_AFPU*)&s_SIN;

static xdata uchar s_SIN[sizeof(MASTER_2_AFPU)];
static MASTER_2_AFPU xdata * xdata s_pSIN = (MASTER_2_AFPU*)&s_SIN;

Parents
  • For question 1, please do consult the C51 manual. 'xdata' is a language extension, and you really have to study the documentation thoroughly to use it.

    As to what this:

    static xdata uchar s_SIN[sizeof(MASTER_2_AFPU)];
    static MASTER_2_AFPU xdata * xdata s_pSIN = (MASTER_2_AFPU*)&s_SIN;
    

    does: this is a somewhat silly detour for defining a pointer to an object of type MASTER_2_AFPU. s_SIN is a buffer of the right size for such an object, but of the wrong type. s_pSIN is meant to access that space as if it were of type MASTER_2_AFPU.

    Whether or not this code is correct or not depends on the unknown definition of MASTER_2_AFPU. If that's anything else but a an array of unsigned char itself, the code is sick.

Reply
  • For question 1, please do consult the C51 manual. 'xdata' is a language extension, and you really have to study the documentation thoroughly to use it.

    As to what this:

    static xdata uchar s_SIN[sizeof(MASTER_2_AFPU)];
    static MASTER_2_AFPU xdata * xdata s_pSIN = (MASTER_2_AFPU*)&s_SIN;
    

    does: this is a somewhat silly detour for defining a pointer to an object of type MASTER_2_AFPU. s_SIN is a buffer of the right size for such an object, but of the wrong type. s_pSIN is meant to access that space as if it were of type MASTER_2_AFPU.

    Whether or not this code is correct or not depends on the unknown definition of MASTER_2_AFPU. If that's anything else but a an array of unsigned char itself, the code is sick.

Children