diff options
Diffstat (limited to 'absl/base/attributes.h')
-rw-r--r-- | absl/base/attributes.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/absl/base/attributes.h b/absl/base/attributes.h index c44b2e893258..a4ec7e7c97c4 100644 --- a/absl/base/attributes.h +++ b/absl/base/attributes.h @@ -543,11 +543,18 @@ // not compile (on supported platforms) unless the variable has a constant // initializer. This is useful for variables with static and thread storage // duration, because it guarantees that they will not suffer from the so-called -// "static init order fiasco". +// "static init order fiasco". Prefer to put this attribute on the most visible +// declaration of the variable, if there's more than one, because code that +// accesses the variable can then use the attribute for optimization. // // Example: // -// ABSL_CONST_INIT static MyType my_var = MakeMyType(...); +// class MyClass { +// public: +// ABSL_CONST_INIT static MyType my_var; +// }; +// +// MyType MyClass::my_var = MakeMyType(...); // // Note that this attribute is redundant if the variable is declared constexpr. #if ABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) |