which attribute syntax should i use ("[[gnu::attr]]" or "__attribute__ ((attr))")

1
2
3
4
5
__attribute__ ((pure))
int foo() {return 2;}

[[gnu::pure]]
int bar() {return 2;}


Both of those attributes do the same thing the second one is not documented in GCC manual

c++ core guidelines recommend using the second method (http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#gsl-guidelines-support-library) (I think)

which one is the preferred method
Last edited on
not sure it matters since it is nonstandard and unportable?
Prefer the latter because it uses the standard attribute syntax.
Last edited on
Topic archived. No new replies allowed.