Part Number: TMS320C6654
Tool/software: TI C/C++ Compiler
Hi,
I have an issue with printf on TMS320C6654 with compiler 8.3.5 when I want to print a data which is not aligned.
Following code reproduce this issue (I use packed attribute to create unaligned data):
typedef struct{
uint8_t idx;
float array[10];
} T_UNPACKED;
typedef struct{
uint8_t idx;
float array[10];
} __attribute__((packed)) T_PACKED;
int main(void)
{
T_UNPACKED data_unpacked;
T_PACKED data_packed;
data_unpacked.array[0] = 51;
data_packed.array[0] = data_unpacked.array[0];
printf("%d:%g - %d:%g\n", data_unpacked.array, data_unpacked.array[0], data_packed.array, data_packed.array[0]);
float* ptr_unpacked = data_unpacked.array;
float* ptr_packed = data_packed.array;
printf("%d:%g - %d:%g\n", ptr_unpacked, ptr_unpacked[0], ptr_packed, ptr_packed[0]);
return;
}
this give me :
9349380:51 - 9349461:51
9349380:51 - 9349461:3.35544e+07
So the printf of the unaligned data accessed by pointer is false (like if pointer have been realigned). My example is with float, but it seems to be the same with other types
Is it a known behaviour? How to avoid it?
Thanks