Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which gnu attributes have c++11 syntax?

Tags:

c++

gcc

c++11

The documentation for C++11 attribute specifier sequence includes examples of GNU namespace attributes, e.g.

[[gnu::always_inline]] [[gnu::hot]] [[gnu::const]] [[nodiscard]]
inline int f(); // declare f with four attributes

The GCC documentation for attributes prior to C++11 uses different syntax

__attribute__(( ... ))

I can't find documentation for which of the GNU attributes use the new [[gnu:foo]] syntax, or what the differences are.

Where is the definitive documentation for this?

like image 722
spraff Avatar asked Dec 09 '25 00:12

spraff


1 Answers

This is a hole in the GCC documentation, and maintainers are aware of it. See GCC Bug 102397 - Documentation of attribute syntax does not discuss C++11 / C23 attribute syntax.

Presently, it looks like all GNU attributes are registered in the gnu:: namespace:

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

gcc-mirror, attribs.cc

like image 72
Jan Schultke Avatar answered Dec 11 '25 12:12

Jan Schultke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!