'-align' option Question
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Options at Command Line Only 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!