__attribute__((???)) ignored
-
whiskey tango, guys
I've always tried to avoid coding where I need to play with compiler directives but I've got some stuff where I need to mark functions as "unused". The offending function is a private static helper function in a compilation unit. It's not activated until I get other parts of the project completed and the warnings annoy my sensibilities.
Anyway, gnu/c++ is "suppose" to support
static void helper() __attribute__((unused));
but regardless of what I try it continues to be flagged as an "unused function" warnign with -Wall during compilation.
I also tried
static void helper() [[unused]];
with equally undesirable results.
my compilation options show "under eclipse IDE" as:
g++ -std=c++17 -I"/home/me/eclipse-2403/farm" -O0 -g3 -Wall -c -fmessage-length=0
What gives, with gnu not accepting function attributes?
-
Hi,
Which version of g++ are you using ?
With which distribution ? -
@Kent-Dorfman said in __attribute__((???)) ignored:
static void helper() [[unused]];
Perhaps [[maybe_unused]]?
The function example also places the attribute before the function signature.
-
that is weird. some examples place the directive after the declaration and others before like it shouldn't matter...but you are right. It did make a different. Placing it before the declation cause the warning to be igrnored.
looks like gcc documention is wrong...go figure. LOL
wrong in TWO PLACES...First, they say "unused" is a valid attribute, and second, internal examples sometimes place the attribute after the decl.
Hmmm.
-
K Kent-Dorfman has marked this topic as solved on