Since C++11/C23, attributes allow compilers to add additional warning/error behaviours for variables, functions/methods, and objects. This can vary greatly from compiler-to-compiler — some are widely supported, but others are specific to a compiler (for example, MSVC has several unique attributes).
Attributes are stored in double square brackets, as followed:
[[ATTRIBUTE_NAME]]A non-exhaustive list of the important attributes supported by most compilers:
[[nodiscard]](C++17, C23) — tags a function/method/type, and allows the compiler to issue a warning if a return value (from a function/method or any type).[[deprecated]](C++14, C23) — marks a function as obsolete and discourages its use. This is intended for functions that are kept in an API to maintain backwards compatibility.