Quantcast
Channel: MSP 低功耗微控制器论坛 - 最近的话题
Viewing all articles
Browse latest Browse all 3634

求助:关于使用IAR编译器开发430过程struct对齐的问题

$
0
0

我现在定义一个变量

#pragma pack(4)

struct test

{

  U4 a;

  U1 b;

  U4 c;

}

#pragma pack()

通过debug看变量地址发现 &c = &b+2,而不是按4字节对齐。

进一步实验发现通过pragma只能实现1字节对齐,设置成4,8字节对齐仍然是按照两字节对齐。

这个是什么问题造成的?


Viewing all articles
Browse latest Browse all 3634

Trending Articles