The thing you are referring to is known as attribute specifiers. It is an attempt to standardize various, platform dependent, specifiers:
As you can see in attached doc link, the only specifiers supported in C++11 are:
[[noreturn]]
[[carries_dependency]]
and in C++14:
[[deprecated]]
(also supported as: [[deprecated("reason")]]
)
C++ 17 is the version that introduces the required feature:
Example from the link:
#include <cassert>
[[maybe_unused]] void f([[maybe_unused]] bool thing1,
[[maybe_unused]] bool thing2)
{
[[maybe_unused]] bool b = thing1 && thing2;
assert(b); // in release mode, assert is compiled out, and b is unused
// no warning because it is declared [[maybe_unused]]
} // parameters thing1 and thing2 are not used, no warning
So the answer is: no, it's not possible, using only C++11 features - the required C++ version to get this in a portable way is C++ 17.
If you are not interested only in portable solutions, there might be a way. C++ standard does not limit this list:
Only the following attributes are defined by the C++ standard. All other attributes are implementation-specific.
Various compilers can support some non-standard specifiers. For example, you can read this page in order to find out, that Clang supports:
Perhaps your version of GCC also supports this specifier. This page contains a bug report referring to generalized attributes support. [[gnu::unused]]
is also mentioned.