#17 pointer initialization in ROM

open
nobody
None
5
2002-02-14
2002-02-13
Corvin Zahn
No

problem with the initialization of pointers sitting in
ROM:

-----------------------------
char ch;

// Pointer in RAM: ok
char* p4 = (char*)(&ch);

// Pointer in ROM: this line results in
// tt2.c(9):warning *** Initializer different levels of
indirections
// and no code is generated
char* const p5 = (char*)(&ch);

// but this line works???
char* const p6 = &ch;
----------------------------

sdcc --version:
SDCC :
mcs51/gbz80/z80/avr/ds390/pic14/i186/tlcs900h/TININative/xa51
2.3.1 (Feb 11 2002) (UNIX)

Any hints?

Corvin

Discussion

  • Johan Knol
    Johan Knol
    2002-02-14

    • labels: 101552 -->
     
  • Johan Knol
    Johan Knol
    2002-02-14

    Logged In: YES
    user_id=63512

    Fixed in SDCCglue.c:1.107

    This isn't perfect yet. You can e.g. not do "char * code p5=
    (char code *)(&ch)" because the cast is simply ignored but
    a warning is thrown in that case, just like with "char *
    code p5=(char code *)0x1234".
    So I moved this one to the feature requests.

    Johan