If a variable is instantiated but not used, the compiler throws a warning.
If this is intentional, C++17 introduced the [[maybe_unused]] attribute to convey this intent.
[[maybe_unused]] double pi { 3.14159 }; // Don't complain if pi is unused
[[maybe_unused]] double gravity { 9.8 }; // Don't complain if gravity is unused
This tells the compiler to not freak out when it sees an unused variable. It suppresses compiler warnings.
It does not change runtime behaviour
[[maybe_unused]] does not make the variable special at runtime.
It does not allocate extra memory. It does not change the value. It does not make the program faster or slower in any meaningful way.
It only affects diagnostics.
This statement:
[[maybe_unused]] int x { 42 };
still declares an int