__attribute__((???)) ignored
-
wrote on 4 Jun 2024, 17:59 last edited by
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 ? -
wrote on 4 Jun 2024, 20:33 last edited by
gcc/g++ 10.2
on Debian 10 -
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?
wrote on 4 Jun 2024, 20:44 last edited by@Kent-Dorfman said in __attribute__((???)) ignored:
static void helper() [[unused]];
Perhaps [[maybe_unused]]?
The function example also places the attribute before the function signature.
-
@Kent-Dorfman said in __attribute__((???)) ignored:
static void helper() [[unused]];
Perhaps [[maybe_unused]]?
The function example also places the attribute before the function signature.
wrote on 4 Jun 2024, 21:03 last edited by Kent-Dorfman 6 Apr 2024, 21:05that 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.
-
1/5