#772 pointer types incompatible?

closed-rejected
Maarten Brock
None
5
2013-05-25
2004-06-14
Anonymous
No

SDCC produces the following error, when I compile the
attached file:
Untitled.c:6: error: pointer types incompatible

I tried with the latest version:
sdcc -v
SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51
/ds400/hc08 2.4.2 (J
un 13 2004) (MINGW32)

I simply could not figure out the right solution so that
every string is stored in code memory and every pointer
is code pointer. I think I have tried every combination.
The goal of the code would be to store "arr0" and "arr1"
strings only once and refer to them in cc[] as initializer.

Could you please check if it is really a bug or there is a
solution that I have missed?

Related to this issue I would like to ask if there is
a "merge duplicate strings" feature in the compiler? (The
aim of this feature is to store constant strings that are
exactly the same only once in code memory.)
By observing the complied assembly file I can see that
some strings are stored only once, but mostly stored as
many times they are initialised.

Regards,

Laszlo BORTEL
bortel.laszlo@ln.matav.hu

Discussion

  • Maarten Brock
    Maarten Brock
    2004-06-14

    Logged In: YES
    user_id=888171

    Laszlo,

    There's no file attached. Please try again or this bug will have
    to be closed as non-reproducable.

    Greets,
    Maarten

     
  • Logged In: NO

    Sorry, the missing code is:

    code char* b[2]={"arr0", "arr1"};
    code struct c {
    code char* d[2];
    } cc[3] = {
    {{"0a", "0b"}},
    {{b[0], b[1]}},
    {{"1a", "1b"}}
    };
    void main (void) {}

     
  • Maarten Brock
    Maarten Brock
    2004-08-02

    • milestone: --> non_bugs
    • assigned_to: nobody --> maartenbrock
    • status: open --> closed-rejected
     
  • Maarten Brock
    Maarten Brock
    2004-08-02

    Logged In: YES
    user_id=888171

    I'm afraid this is no bug. This code looks like:

    const char b = 1;
    char c = b;
    void main(void) {}

    Allthough it should be possible to parse this, this is not in the
    standard and there is no compiler I know of that implements
    this.

    Maybe the best solution would be something like:

    const char b0[] = "arr0";
    const char b1[] = "arr1";

    const struct c {
    const char* d[2];
    } cc[2] = {
    {{"0a", "0b"}},
    {{b0, b1}}
    };

    Closing this now.
    Maarten