Topic : Compile issues on struct and union

Forum : ST7/STM8

Original Post
Post Information Post
October 13, 2009 - 10:12am
Guest

Hi To All

Can someone tell me why this kind of struct union has issue in compiling:
Compiler version is: RCSTM8 COMPILER V2.17.09.139 Lite (16 Kb code limited)

typedef union
{
struct
{
UINT8 b0:1;
UINT8 b1:1;
UINT8 b2:1;
UINT8 b3:1;
UINT8 b4:1;
UINT8 b5:1;
UINT8 b6:1;
UINT8 b7:1;
} bit;
UINT8 data;
} BYTEFLAGS;

Thank's to all

Ipur.

Replies
Post Information Post
+1
0
-1
October 13, 2009 - 10:33am
Guest

bit and data are reserved keywords (space qualifiers). You may not use them as identifiers.
The following code will be ok:

typedef union
{
   struct
   {
       UINT8   b0:1;
       UINT8   b1:1;
       UINT8   b2:1;
       UINT8   b3:1;
       UINT8   b4:1;
       UINT8   b5:1;
       UINT8   b6:1;
       UINT8   b7:1;
   } bitval;
   UINT8 dataval;
} BYTEFLAGS;
+1
0
-1
October 13, 2009 - 10:35am
Guest

PS

Key words usually appear in a different color (red in my case)

Regards,

+1
0
-1
October 13, 2009 - 12:24pm
Guest

Thank's matloud!!

Sorry for the stupid question... didn't find out a way to solve this. I'm using an external editor instead of ride7 so didn't notice the keywords.

Ipur

+1
0
-1
August 13, 2014 - 4:33am
Guest

Would anybody happen to know why this doesn't compile? I used it on a PIC compiler before and was ok.

In the .h file:

typedef struct Calibrate_t
{
union
{
struct
{
uint8_t RunCurrent[2];
uint8_t StallCurrent[2];
uint8_t RunTime[2];
uint8_t RunTimeMax[2];
uint8_t StallTimeState[2];
uint8_t ReverseWhenStall;
uint8_t Spare1;
uint8_t Spare2;
};
uint8_t CalibrationArray[13];
};
}Calibrate_t;
extern Calibrate_t calibrate;

In the .c file

Calibrate_t calibrate;

The compiler error i am getting is:

*** ERROR C074 IN LINE 169 OF DATABASE.H : Invalid declaration syntax
*** ERROR C131 IN LINE 184 OF DATABASE.H : unbalanced #if-endif controls

I would like to be able to access the variables in main for example with the following syntax:

+1
0
-1
August 13, 2014 - 2:25pm
Raisonance Support Team

this is a different question, so we put it in a different topic:
http://forum.raisonance.com/viewtopic.php?pid=16261#p16261