【发布时间】:2016-12-15 08:52:44
【问题描述】:
我正在尝试在具有尾随类型的自动函数上使用 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
;
【问题讨论】:
标签: c++ function gcc attributes auto