哪些 gnu 属性具有 c++11 语法?

spr*_*aff 6 c++ gcc gnu c++11

C++11 属性说明符序列的文档包括 GNU 命名空间属性的示例,例如

[[gnu::always_inline]] [[gnu::hot]] [[gnu::const]] [[nodiscard]]
inline int f(); // declare f with four attributes
Run Code Online (Sandbox Code Playgroud)

C++11 之前的属性的GCC 文档使用不同的语法

__attribute__(( ... ))
Run Code Online (Sandbox Code Playgroud)

我找不到关于哪些 GNU 属性使用新[[gnu:foo]]语法或有什么区别的文档。

这方面的权威文档在哪里?

Jan*_*tke 1

这是 GCC 文档中的一个漏洞,维护人员也意识到了这一点。请参阅GCC Bug 102397 - 属性语法文档未讨论 C++11/C23 属性语法

目前,看起来所有GNU 属性都已在gnu::命名空间中注册:

/* Put all the GNU attributes into the "gnu" namespace.  */
register_scoped_attributes (attribute_tables[i], "gnu");
Run Code Online (Sandbox Code Playgroud)

海湾合作委员会镜像,attribs.cc