This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
dear All,
where and how is done the data structure alignment in a ccs project ( by ALIGN directive )?
regards,
Ras
From looking at your other threads, I can tell you use a C2000 device.
Consider this line of C code ...
int table[100];
For this line the compiler generates this assembler directive ...
_table: .usect ".ebss",100,1,0
You can try that yourself. Be sure to use the compiler switch -k, which tells the compiler to not delete the auto-generated assembly file. It has the same name as the source file, with the extension changed to .asm. The .usect directive reserves space in an uninitialized section named .ebss. You can read more about .usect in the C2000 assembly tools manual.
Now suppose you need this table to have a higher alignment. You can use the DATA_ALIGN pragma for that. For example ...
#pragma DATA_ALIGN(table, 32) int table[100];
This generates the assembly output ...
_table: .usect ".ebss",100,1,5
Notice the last number changes from 0 to 5. The 0 means no alignment needed. The 5 means align on a 32-word boundary, because 2 ** 5 is 32.
Thanks and regards,
-George