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

autoreferencial structure in ROM

Dear Sir,

I use a structure like this one:

typedef struct st { char t; struct st*;}

I would like to store several structures in ROM.
I wrote the following code

const struct st1 = { 1, &st2};
const struct st2 = { 2, &st1);

The compilation produce an undefined identifier error 202 (c51 V4.02).

What can I do to solve this problem?

Best regards

Parents
  • First check if this will compile:
    //--------------
    typedef struct st { char t; void * st;};
    const struct st st1 = { 1, NULL};
    const struct st st2 = { 2, &st1};
    //--------------
    You left the ";" of the end of the typedef statement, and also the structure tag was missing in the const declarations.

    I was testing this in another C compiler, and the first constant failed, because st2 had not yet been defined. I am not sure if Keil can handle a forward reference like this.

Reply
  • First check if this will compile:
    //--------------
    typedef struct st { char t; void * st;};
    const struct st st1 = { 1, NULL};
    const struct st st2 = { 2, &st1};
    //--------------
    You left the ";" of the end of the typedef statement, and also the structure tag was missing in the const declarations.

    I was testing this in another C compiler, and the first constant failed, because st2 had not yet been defined. I am not sure if Keil can handle a forward reference like this.

Children
No data