[ARM入门] 求问IAR编译器中字节对齐问题

[复制链接]
10809|8
 楼主| vosamo007 发表于 2014-3-26 22:01 | 显示全部楼层 |阅读模式

程序段如图所示,先是定义了一个结构体channel_ctrl,然后定义了一个结构体数组channel_ctrl channel_config[UDMA_CONF_MAX_CHANNEL + 1],对齐方式为__attribute__ ((aligned(1024))),编译时报错:Error[Pe065]: expected a ";" 该怎么解决?菜鸟求大神解救!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
ayb_ice 发表于 2014-3-28 08:50 | 显示全部楼层
先全部屏蔽掉,然后写一点编译一点,就知道哪里有问题了
jplzl 发表于 2014-3-29 14:09 | 显示全部楼层
估计是后缀说明没写对
aozima 发表于 2014-3-29 14:26 | 显示全部楼层
rtdef.h
  1. /* Compiler Related Definitions */
  2. #ifdef __CC_ARM                         /* ARM Compiler */
  3.     #define ALIGN(n)                    __attribute__((aligned(n)))
  4. #elif defined (__IAR_SYSTEMS_ICC__)     /* for IAR Compiler */
  5.     #define ALIGN(n)                    PRAGMA(data_alignment=n)
  6. #elif defined (__GNUC__)                /* GNU GCC Compiler */
  7.     #define ALIGN(n)                    __attribute__((aligned(n)))
  8. #elif defined (__ADSPBLACKFIN__)        /* for VisualDSP++ Compiler */
  9.     #define ALIGN(n)                    __attribute__((aligned(n)))
  10. #elif defined (_MSC_VER)
  11.     #define ALIGN(n)                    __declspec(align(n))
  12. #endif /* Compiler Related Definitions */
  1. #define RT_ALIGN_SIZE  8
  2. ALIGN(RT_ALIGN_SIZE)
  3. static char finsh_thread_stack[2048];
 楼主| vosamo007 发表于 2014-4-3 09:50 | 显示全部楼层
aozima 发表于 2014-3-29 14:26
rtdef.h

请问这个rtdef.h文件是在哪里?意思是我直接用ALIGN(n)进行字节对齐吗?
aozima 发表于 2014-4-3 09:52 | 显示全部楼层
rtdef.h是RT-Thread的头文件。

截取这部分是告诉你几大常见编译器的不同写法。
可以像这样写一个定义,以方便不同平台的移植。
 楼主| vosamo007 发表于 2014-4-3 10:15 | 显示全部楼层
aozima 发表于 2014-4-3 09:52
rtdef.h是RT-Thread的头文件。

截取这部分是告诉你几大常见编译器的不同写法。

哦,谢谢!那有没有关于不同编译器对_attribute((naked))_的定义啊?
aozima 发表于 2014-4-3 10:25 | 显示全部楼层
vosamo007 发表于 2014-4-3 10:15
哦,谢谢!那有没有关于不同编译器对_attribute((naked))_的定义啊?

自己查编译器的文档呀。
 楼主| vosamo007 发表于 2014-4-3 20:07 | 显示全部楼层
aozima 发表于 2014-4-3 10:25
自己查编译器的文档呀。

我用的是IAR编译器,查过了,没有找到。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

5

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部