Okay, what am I missing....
I wrote the code originally on an IAR IDE/compiler for use on an ARM microprocessor and it worked fine.
We are now switching to a different controller with a Tricore microprocessor and are now using code::blocks IDE with GNU GCC compiler for TriCore v3.4.6.
When building I am getting the errors with the below two structures (related enums given for reference):
01| typedef enum equip_states_t {
02| stopped = 0,
03| starting = 1,
04| running = 2,
05| paused = 3,
06| stopping = 4
07| }equip_states_t;
08|
09| typedef enum info_level_t{
10| clear = 0,
11| alert = 1,
12| warning = 2,
13| error = 3
14| } info_level_t;
15|
16| typedef struct d2101_equip_states_t {
17| equip_states_t AIR_COMP_state:4; //Error starts here
18| pause_states_t auto_pause_state:4;
19| fullness_states_t BE_fullness:4;
20| equip_states_t BE_state:4;
21| fullness_states_t BIN_fullness:4;
22| bin_states_t BIN_state:4;
23| bin_states_t BYPASS_state:4;
24| control_modes_t control_mode:4;
25| equip_states_t DC_state:4;
26| source_dest_t DIV_auto_pause:4;
27| source_dest_t DIV_position:4;
28| equip_states_t HYDR_state:4;
29| equip_states_t QL_state:4;
30| fullness_states_t TC_fullness:4;
31| equip_states_t TC_state:4;
32| equip_states_t TUC_state:4;
33| } d2101_equip_states_t;
34|
35| typedef struct info_message_t {
36| uint16_t ID; //Error starts here
37| info_level_t status:8;
38| uint8_t not_used;
39| uint32_t time_stamp:32;
40| } info_message_t;
The errors are:
[18] error: [11705] syntax error before "pause_states_t"
[18] warning: [11407] no semicolon at end of struct or union
[19] error: [11707] syntax error before ':' token
[20] error: [11707] syntax error before ':' token
[21] error: [11707] syntax error before ':' token
[24] error: [11707] syntax error before ':' token
[25] error: [11707] syntax error before ':' token
[26] error: [11707] syntax error before ':' token
[27] error: [11707] syntax error before ':' token
[28] error: [11707] syntax error before ':' token
[29] error: [11707] syntax error before ':' token
[30] error: [11707] syntax error before ':' token
[31] error: [11707] syntax error before ':' token
[32] error: [11707] syntax error before ':' token
[33] warning: [13263] type defaults to 'int' in declaration of 'd2101_equip_states_t'
[33] warning: [10516] data definition has no type or storage class
[37] error: [11705] syntax error before "info_level_t"
[37] warning: [11407] no semicolon at end of struct or union
[39] error: [11707] syntax error before ':' token
[40] warning: [13263] type defaults to 'int' in declaration of 'info_message_t'
[40] warning: [10516] data definition has no type or storage class
HOWEVER... In many, many other instances, including some before and after in the same file, I use the same syntax with no errors and hence my confusion on what is going wrong. E.G.
typedef struct rmt2001_feedback_to_remote_t{
uint8_t screen_number;
bool fault_present:1;
switch_states_t DC:1;
switch_states_t air:1;
switch_states_t HYDR:1;
switch_states_t TUC:1;
switch_states_t BE:1;
switch_states_t TC:1;
switch_states_t green_backlight:1;
source_dest_t dest:3;
equip_states_t status:3;
switch_states_t red_backlight:1;
switch_states_t blue_backlight:1;
uint8_t gate_percent;
uint8_t bin_percent;
uint8_t BE_amps_msb;
uint8_t BE_amps_lsb;
uint8_t not_used;
} rmt2001_feedback_to_remote_t;
typedef struct IO_view_t{
master_or_slave_t master_or_slave:1;
uint8_t exponent:3;
uint8_t controller_id:4;
uint8_t io_id:6;
A_of_D_t A_or_D:1;
I_or_O_t I_or_O:1;
uint16_t raw;
int16_t value;
} IO_view_t;
If I remember correctly what I have read elsewhere on this site is that structure bit packing isn't very consistent between compilers as it's not clearly/strictly defined by c standard. I also read that using bitwise operations with masks and offsets is a more cross platform friendly way of doing bit packing and failing anything else I can do that.... But I want to know why this doesn't work in only these two instances and I am hoping there is some simple little thing that will save me from having to do this.
Thank you everyone for your time in reading this.