Part Number: F28M35H52C
Tool/software: TI C/C++ Compiler
Hello,
I'm facing an issue on my concerto and I am looking for help.
Let's try summarize the issue :)
I want to share an enum between ARM and C28.
This enum is "small" and could be encoded in a char. I "packed" structure to be sure that alignement doesn't hide my problem.
I summarize my code with the simple example following :
#if defined(__TMS320C2000__)
// struct is packed by default on the DSP
#define STRUCT_PACKED
#elif defined(__TI_ARM__)
#define STRUCT_PACKED __attribute__((__packed__))
#endif
typedef enum {
A,
B,
C
} FOO;
struct STRUCT_PACKED test
{
FOO enumValue;
uint16_t numericValue;
}
By default, the compiler will see this both enum with this size :
- ARM -> Int -> 32 bit
- C28 -> Int -> 16 bit
- NOK, we have here a clear misalignement between the both proc.
Different options seems available about enum on compilers :
- ARM -> --small_enum
- ARM -> --enum_type (packed/int)
- C28 -> did not find any option about enum size, but the strict C89/C99 option.
Admit that I enable one of theses option, what happened ?
ARM compiled with --small_enum enabled :
ARM -> char -> 8 bit
C28 -> Int -> 16 bit
NOK
ARM compiled with --enum_type=int
ARM -> Int -> 32 bit
C28 -> Int -> 16 bit
NOK
ARM compiled with --enum_type=packed
ARM -> Int -> 32 bit
C28 -> Int -> 16 bit
NOK
Is there a "clean" way to compile the both side properly ?
What is your recommandation to handle properly such situations ?
Many thanks !
Cheers,
T.