We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
Try this:
struct st { char t; struct st *ptr;}; const struct st st2; const struct st st1 = { 1, &st2}; const struct st st2 = { 2, &st1};
I have tried before to declare the structure as Mike suggests, but it doesn't work (error of multiple definition). In fact, this works with Turbo C, it was like that in my original sources I try to switch to C51. In the meantime I found the following code using an array which works: struct st { char t; struct st *ptr;}; const struct st ast[2] = { { 1, &ast[1]}, { 2, &ast[0]}}; Thanks
OK, this code must work (note the extern keyword):
struct st { char t; struct st *ptr;}; extern const struct st st2; const struct st st1 = { 1, &st2}; const struct st st2 = { 2, &st1};