Opened 11 years ago
Closed 11 years ago
#470 closed defect (fixed)
"Unused locally defined typedef" warning with gcc 4.8
Reported by: | Alpar Juttner | Owned by: | Alpar Juttner |
---|---|---|---|
Priority: | critical | Milestone: | LEMON 1.3 release |
Component: | core | Version: | hg main |
Keywords: | Cc: | ||
Revision id: |
Description
The warnings look very stupid, but makes Maintainer
more fail.
Is there a compiler pragma for switching off this warning locally?
/home/alpar/projects/LEMON/hg/cplex-comp/lemon/core.h:109:38: warning: typedef ‘OutArcIt’ locally defined but not used [-Wunused-local-typedefs] typedef typename Digraph::OutArcIt OutArcIt; \ ^ /home/alpar/projects/LEMON/hg/cplex-comp/lemon/core.h:143:3: note: in expansion of macro ‘TEMPLATE_DIGRAPH_TYPEDEFS’ TEMPLATE_DIGRAPH_TYPEDEFS(Graph); \ ^ /home/alpar/projects/LEMON/hg/cplex-comp/test/graph_test.cc:34:3: note: in expansion of macro ‘TEMPLATE_GRAPH_TYPEDEFS’ TEMPLATE_GRAPH_TYPEDEFS(Graph); ^ /home/alpar/projects/LEMON/hg/cplex-comp/lemon/core.h:110:52: warning: typedef ‘BoolNodeMap’ locally defined but not used [-Wunused-local-typedefs] typedef typename Digraph::template NodeMap<bool> BoolNodeMap; \ ^
Change History (8)
comment:1 follow-up: 2 Changed 11 years ago by
comment:2 Changed 11 years ago by
Replying to alpar:
So, currently the only solution I could find is to globally switch this warning off in
lemon/core.h
with#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
I merge this to branches 1.1, 1.2 and default, see [756022ac1674]
comment:4 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 follow-up: 6 Changed 11 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I reopened this ticket because it seems that this solution causes a compiler warning with GCC 4.5.x:
lemon/core.h:42:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind
Can we avoid this warning? Or is it acceptable?
comment:6 Changed 11 years ago by
Replying to kpeter:
Can we avoid this warning?
Yes we can, by applying the #pragma
only to gcc version >=4.8. It is done in [6039b32a2351]. Futhermore, [115031ac8001] adds two other gcc backward compatibility fixes. Both chgsets are merged to branches 1.1, 1.2, and the main one.
Now, all these branches compiles in Maintainer
mode with
- GNU GCC versions 3.3, 4.3, 4.5, 4.7 and 4.8 and
- Intel C++ 2011 and 2013
Or is it acceptable?
Not really. In fact, the
Maintainer
build mode converts all the warnings to errors.
comment:8 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
It is not that easy. The point is that
[TEMPLATE_]GRAPH_TYPEDEFS
provides a bunch of convenience typedefs, many of which will be unused, of course.First I tried to write something similar to
ignore_unused_variable_warning(v)
like this:It works well for local typedefs. However,
TEMPLATE_GRAPH_TYPEDEFS
may also be used outside a function body (e.g. in a class or in the global scope), when the above solution fails.Then, I tried to use a
#pragma
directive to switch this warning off locally, something like:However,
#pragma
cannot be used within#define
. There are compiler dependent alternatives (_Pragma(...)
on gcc,__pragma(...)
on VC), but I couldn't have it worked.So, currently the only solution I could find is to globally switch this warning off in
lemon/core.h
withWhat do you think?