C++11 属性说明符序列的文档包括 GNU 命名空间属性的示例,例如
[[gnu::always_inline]] [[gnu::hot]] [[gnu::const]] [[nodiscard]]
inline int f(); // declare f with four attributes
C++11 之前的属性的GCC 文档使用不同的语法
__attribute__(( ... ))
我找不到关于哪些 GNU 属性使用新[[gnu:foo]]语法或有什么区别的文档。
这方面的权威文档在哪里?
这是 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");