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

Declare variable in the same location as that of a struct member

Hi All,
Am trying to re-write a code in PLM51 to embedded C.
There is a statement in PLM51 as below.

DECLARE TASK(17) STRUCTURE(PNTR BYTE,STATUS BYTE,DELAY WORD);
DECLARE DELAY_HEAD BYTE AT (.TASK(0).PNTR); //ERROR LINE//

What i have understood from this is-- DELAY_HEAD is a byte variable which resides at the same location as that of TASK(0).PNTR.(From the PLM51 manual)

I have rewritten the same into C as below.

struct tsk
{ unsigned char PNTR ; unsigned char STATUS; unsigned int DELAY;
}TASK[17];
unsigned char DELAY_HEAD _at_ &TASK[0].PNTR ;

But its giving error 221:non-constant case/dim expression.
Plss help..!!

Parents
  • Hi,
    As you have said,i have removed that linker directive and checked in the MAP file.Its given as here.

    
    SYMBOL TABLE OF MODULE:  mp15 (PMOB)
    VALUE       REP       CLASS    TYPE      SYMBOL NAME
    .....
    LX51 LINKER/LOCATER V3.64
    .....
    
    010030EBH   SYMBOL    CONST    BYTE      MEM_VAL
    00000010H   SYMBOL    IDATA    ---       MEM_PTR
    00000013H   SYMBOL    IDATA    WORD      CHECK
    010030E9H   SYMBOL    CONST    WORD      CONTROL1
    
    
    
    
    BASE START END USED MEMORY CLASS ========================================================== C:000000H C:000000H C:00FFFFH 002F1DH CODE X:000000H X:000000H X:00FFFFH 0001C8H XDATA I:000020H.0 I:000020H.0 I:00002FH.7 000002H.2 BIT C:000000H C:000000H C:00FFFFH 0001BEH CONST I:000000H I:000000H I:0000FFH 00006CH IDATA I:000000H I:000000H I:00007FH 000018H DATA


    In the above table its given CODE memory class range as 0000-FFFF.But my EPROM size is 0000-7FFF.I have given that in the OPTIONS->TARGET->Off-chip CODE Memory as 0x0000,0x8000.Pls check this.

    tHANKS

Reply
  • Hi,
    As you have said,i have removed that linker directive and checked in the MAP file.Its given as here.

    
    SYMBOL TABLE OF MODULE:  mp15 (PMOB)
    VALUE       REP       CLASS    TYPE      SYMBOL NAME
    .....
    LX51 LINKER/LOCATER V3.64
    .....
    
    010030EBH   SYMBOL    CONST    BYTE      MEM_VAL
    00000010H   SYMBOL    IDATA    ---       MEM_PTR
    00000013H   SYMBOL    IDATA    WORD      CHECK
    010030E9H   SYMBOL    CONST    WORD      CONTROL1
    
    
    
    
    BASE START END USED MEMORY CLASS ========================================================== C:000000H C:000000H C:00FFFFH 002F1DH CODE X:000000H X:000000H X:00FFFFH 0001C8H XDATA I:000020H.0 I:000020H.0 I:00002FH.7 000002H.2 BIT C:000000H C:000000H C:00FFFFH 0001BEH CONST I:000000H I:000000H I:0000FFH 00006CH IDATA I:000000H I:000000H I:00007FH 000018H DATA


    In the above table its given CODE memory class range as 0000-FFFF.But my EPROM size is 0000-7FFF.I have given that in the OPTIONS->TARGET->Off-chip CODE Memory as 0x0000,0x8000.Pls check this.

    tHANKS

Children