将GCC功能属性放置在自动功能中
Where to place gcc function attribute in auto function
我正在尝试使用带有尾随类型的自动函数上的GCC函数属性,但是GCC编译器一直拒绝代码。我正在基于GCC属性的位置在此处的示例上:
https://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc/function-attributes.html
// ok
int my_int_gcc_func ()
__attribute__(( abi_tag ("tag1") , weak )) //ok
;
// error
auto my_auto_gcc_func_not_working ()
__attribute__(( abi_tag ("tag2") , weak )) // error
-> int
// cant place attribute here, get different warning..
;
参考文档立即将属性放在函数参数之后。
我注意到我可以在整个函数声明前移动属性关键字,但找不到任何正式规范,说明这是GCC允许/支持的...
// ok
__attribute__(( abi_tag ("tag2") , weak )) // seems ok
auto my_auto_gcc_func_no_error ()
-> int
;
似乎允许在函数声明前使用属性关键字。
我在gcc
属性语法规范中找到的以下规则:
使用单个指定符和预选赛列表的声明列表中,在逗号分隔的声明列表中,可能会立即出现在声明器(除第一个)列表中。
和
属性指定列表可能会立即出现在逗号=或半隆终止函数定义以外的标识符声明。此类属性指定符适用于声明的对象或函数。
相关文章:
- 具有sleep_for和sleep_until功能的 gcc 可能存在的问题
- 是否可以在gcc中只启用特定的C++语言功能
- AVR-GCC:(看似)简单功能中不需要的序言/尾声
- 为什么 GCC 没有为我决定内联或不内联这个功能?
- C 11螺纹 - 非静态成员功能的使用无效 - 工作GCC 5.1.0损坏的GCC 7.3.1
- GCC / DIAB:保持未使用的功能 /部分
- 模板类中的静态功能:GCC与VS
- 为什么GCC违反了调用ABS功能的代码,并用简短的参数进行功能
- 如何求解与GCC/Clang不同的C 功能模板的MSVC处理(无法识别的模板定义)
- GCC称将功能与多个继承过载时,称其为模棱两可,但Clang和MSVC没有
- 未定义的引用指针的变量模板在clang中功能,而不是GCC
- 从GCC功能树节点中检索函数参数
- C++11 具有与不同版本的 GCC 兼容的功能
- 如何获得GCC版本支持特定功能
- 将GCC功能属性放置在自动功能中
- GCC vs Clang:将功能与-FPIC一起插入
- GCC 是否可以修改 C++ 功能的 C 标头
- 在PowerPC编译器上删除功能,而不是GCC上的功能
- C GCC功能模板超载编译器问题
- 要使 gcc 4.8.1 支持 c++11 中的新"auto"功能?