Topic: RCST7: Always prefer the UNSIGNEDCHAR directive
The code generated for signed char is less optimal than the one produced for unsigned chars. This is due to the ST7 architecture.
Moreover, when using enumerations, RCST7 has the capability of using the enum values as if they were of char type (the C standard mandates that enum values should be of int type).
In the following snippet of code, the DISABLED enum value is defined as 0x80.
- If the UNSIGNEDCHAR directive is activated, then the enum can be treated as a char.
- But if the SIGNEDCHAR directive is applied instead, the compiler will have to convert the Init_Value valiable to an int, which will produce much bigger code.
Conclusion:
Use the UNSIGNEDCHAR directive whenever possible (it is the default option for RCST7). And enforce this requirement when using enums with ENUMTYPE(char) activated.
#pragma SIGNEDCHAR ET(CHAR)
typedef enum {
DEFAULT = 0x00,
ENABLED = 0x01,
DISABLED = 0x80
} ENUMTYPE;
void check(ENUMTYPE Init_Value)
{
if (Init_Value & 0x80)
{
/* ... some code */ ;
}
}