2.6.9 Attributes

Maybe have you already seen the __attribute__ token in some C++ code? This is used to annotate the code with hints or directives about some code. Unfortunately it is a compiler extension, so it was not usable in portable code.

Starting with C++11, we now have a standard way to specify attributes with the [[some_attribute]] syntax. Their semantic is still implementation-defined but at least it is syntaxically portable.

One of the only two well defined attributes in the C++11 standard is [[noreturn]], which tells that a function never returns to the caller:

[[noreturn]] void fatal_error(const char* m) 
  printf("%s\n", m); 

The second one is [[carries_dependency]] and I won’t talk about it.