I am trying to move a project from GNU C to Codewarrior.
The first sticking point came up right away in the bit-fields:
| typedef union {
| uint8 byte;
| struct {
| uint8 BIT7 : 1; <- Warning: C1106 Non-Standard bitfield type
| uint8 BIT5 : 1; <- Warning: C1106 Non-Standard bitfield type
| uint8 BIT4 : 1; <- Warning: C1106 Non-Standard bitfield type
| uint8 BIT2 : 1; <- Warning: C1106 Non-Standard bitfield type
| uint8 BIT1 : 1; <- Warning: C1106 Non-Standard bitfield type
| uint8 BIT0 : 1; <- Warning: C1106 Non-Standard bitfield type
| }bit;
|}reg08;
|typedef union {
| uint16 word;
| struct {
| uint16 BIT15 : 1;
| uint16 BIT14 : 1;
| uint16 BIT13 : 1;
| uint16 BIT12 : 1;
| uint16 BIT11 : 1;
| uint16 BIT10 : 1;
| uint16 BIT9 : 1;
| uint16 BIT8 : 1;
| uint16 BIT7 : 1;
| uint16 BIT6 : 1;
| uint16 BIT5 : 1;
| uint16 BIT4 : 1;
| uint16 BIT3 : 1;
| uint16 BIT2 : 1;
| uint16 BIT1 : 1;
| uint16 BIT0 : 1;
| }bit;
}reg16;
|
|enum { BIT15 = 0x8000, <- Error C1014: Integral type expected or enum value out of range
| BIT14 = 0x4000,
| BIT13 = 0x2000,
| BIT12 = 0x1000,
| BIT11 = 0x0800,
| BIT10 = 0x0400,
| BIT9 = 0x0200,
| BIT8 = 0x0100 };
.. that is, a warning each time 'uint8' is used in the enumeration, no warning when 'unit16' is used and an error when 'BIT15' is assigned a value over 32767, defined, as if it is actually a signed value
Changing the first eight to 'uint16' removes the first eight warnings, but the error has me stumped
Wade Hassler
Solved! Go to Solution.
Hello Wade,
I assume that the type uint8 is defined as unsigned char. This should not cause a bitfield warning unless you have specifically enabled "strict ANSI" compiler option. Have you included the device header file for the target MCU, that is present within the CW installation? This header file also makes extensive use of bitfields of non-standard type unsigned char, normally without warning messages being generated.
However, the device header file may also cause a conflict with your code, since here byte is also typedef'ed as unsigned char, and word as unsigned int.
Additionally, the bit allocation sequence used by CW is the opposite of what you seem to be assuming - the LSB is allocated first. Of course this should not matter if you are using the bitfield simply as a series of single bit flags.
With respect to the enum, CW does define this as a signed int value, so the error message is valid.
Regards,
Mac
Hello Wade,
I assume that the type uint8 is defined as unsigned char. This should not cause a bitfield warning unless you have specifically enabled "strict ANSI" compiler option. Have you included the device header file for the target MCU, that is present within the CW installation? This header file also makes extensive use of bitfields of non-standard type unsigned char, normally without warning messages being generated.
However, the device header file may also cause a conflict with your code, since here byte is also typedef'ed as unsigned char, and word as unsigned int.
Additionally, the bit allocation sequence used by CW is the opposite of what you seem to be assuming - the LSB is allocated first. Of course this should not matter if you are using the bitfield simply as a series of single bit flags.
With respect to the enum, CW does define this as a signed int value, so the error message is valid.
Regards,
Mac