Using structs in a struct

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
samsonbox
Posts: 16
Joined: 06 Sep 2016 22:42

Using structs in a struct

Post 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
ftrueck
Posts: 41
Joined: 24 Dec 2015 23:46

Re: Using structs in a struct

Post 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
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: Using structs in a struct

Post by p0lyg0n1 »

Hi, samsonbox. Please upgrade to latest stable release 2.0.6. We have fixed this issue.
Post Reply