最近在看项目代码的时候发现了新大陆,之前从没有用过__attribute__,
根据代码和网上看到的资料,总结一下 __attribute__ 的常用用法~
1.__attribute__((packed))取消结构体对齐。
用例:
typedef struct __attribute__((packed))
{
UBYTE sts;
}ST_USB_POWER_RES;
2.__attribute__((__noreturn__)) 告诉编译器,函数不会返回
void __throw_bad_typeid(void) __attribute__((__noreturn__));
3.将变量定义在特定位置
static unsigned char Uart12_Send_Data_Buf [LOG_SEND_BUF_SIZE] __attribute__ ((section (".uncache_edram")))= {0};
最后
以上就是乐观云朵最近收集整理的关于__attribute__ 用法的全部内容,更多相关__attribute__内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复