Page 1 of 1

Using structs in a struct

Posted: 03 Oct 2016 22:37
by samsonbox
Hello together,

when i try to use a stuct in a second struct like this:

Code: Select all

struct s1{
  byte b1;
};
struct s2 {
  s1 s;
  byte b2;
};
i always get the following comiler error:

Code: Select all

C:\Users\xxx\AppData\Local\Temp\build6209164666085632177.tmp\_test_ucxx.c:272: syntax error: token -> 'static' ; column 11
Error. SDCC returned: 1
The preprocessed code in the file metionend in the error looks like this:

Code: Select all

struct s1 
{
     unsigned char b1;
};
struct s2 
{
     static struct s1 __xdata s;
     unsigned char b2;
};
so the compiler is right. The keyword static is not correct here. Can i prevent the preprocessor doing this replacement? Is there a workaround?

thank you for your answers

Re: Using structs in a struct

Posted: 04 Oct 2016 01:42
by ftrueck
I admit I do not have much Ansi C Experience.
Maybe you can try to use a pointer to s1 instead of a copy?

Regards,
Florian

Re: Using structs in a struct

Posted: 08 Oct 2016 15:55
by p0lyg0n1
Hi, samsonbox. Please upgrade to latest stable release 2.0.6. We have fixed this issue.