gnu gcc How to suppress warning: ‘typedef’ was ignored in this declaration [enabled by default]
Solution 1
-Wno-unused-local-typedefs works in gcc 4.8 for me.
Solution 2
gcc allows you to specify that certain library include paths should be treated as system libraries with the -isystem
switch which allows those headers special treatment with respect to the flags you use on the rest of your code. So for example if you have unused local typedefs from using certain Boost libraries in test.cpp
(I ran into this using including the Boost signals2
library recently)
g++ -o test{,.cpp} -Wall -Wextra -Werror -I /usr/local/boost-1.55.0/include -L /usr/local/boost-1.55.0/lib
and the above does not build cleanly try the following
g++ -o test{,.cpp} -Wall -Wextra -Werror -isystem /usr/local/boost-1.55.0/include -L /usr/local/boost-1.55.0/lib
which will (provided the warnings coming from the Boost libraries you are including in test.cpp
are your only problem of course).
Solution 3
According to the gcc-source-code(gcc/cp/decl.c:4108):
warning (0, "%<typedef%> was ignored in this declaration");
There is no command line flag(that is what the 0 stands for) to suppress this warning in gcc 4.6.2.
Solution 4
As -Wunused-local-typedef
is part of -Wall
, make sure you don't have -Wall
after -Wno-unused-local-typedef
. If you do, -Wall
just turns the option back on again.
2607
Updated on January 02, 2020Comments
-
2607 over 4 years
I am using GNU gcc 4.6.2 on Fedora 16. I am writing an application using a 3rd party API, after compilation, I got a lot warnings.
warning: ‘typedef’ was ignored in this declaration [enabled by default]
Just wondering how can I suppress this? I compile my program with -Wall flag.
In this doc, http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html, it mentioned something like -Wunused-local-typedefs.
I have tried -Wno-unused-local-typedefs, but doesn't work.
Thanks.