'-align' option Question
3 views (last 30 days)
Show older comments
Hello,
I have some open points regarding the usage of ‘-align’ option (I set it in Configuration/ Advanced Settings options for a project):
Question 1: Is this ‘-align’ setting affecting only the storage units inside of a struct Or Is it also overriding the alignment value checked in “Target processor type” options?
Question 2: How is the alignment inside a struct - forced with a bitfield_t xxx :0 construct- interpreted? see sample code below start at next: a)byte; b) int c) as specified by ‘-align’ d) alignment option for the mcu ?
Settings used: -Char 8bits signed, Short 16bits, Int 16bits. - Endianess: Little endian. -Alignment: 32 bits. -Target OS: no-predefined-os. Advanced setting used: -align 8
Sample Code: typedef unsigned int bitfield_t;
union sfrByte_t { int value; struct { bitfield_t bit0 : 3; bitfield_t xxx :0; bitfield_t bit1 : 1; bitfield_t bit7 : 1; } byteFields; } ; union sfrByte_t sfrByte;
void f () { unsigned short var1; sfrByte.value = 0x5A; var1 = sfrByte.byteFields.bit1;
}
void main() { f(); }
Thank you for your kind support, Daniel
0 Comments
Answers (0)
See Also
Categories
Find more on Options at Command Line Only in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!