Opened 7 years ago

Closed 7 years ago

#15137 closed defect (fixed)

Suppress tons of "unused local typedef" warning from g++ 4.8

Reported by: vadz Owned by:
Priority: low Milestone: 3.0.0
Component: build Version: stable-latest
Keywords: g++ warning Cc: minorinoki@…
Blocked By: Blocking:
Patch: yes

Description

Since 4.8, -Wunused-local-typedefs is part of -Wall and so is enabled by default. Unfortunately it results in tons of warnings when building wx:

In file included from /src/wx/HEAD/include/wx/wxprec.h:13:0,
                 from /src/wx/HEAD/src/common/any.cpp:13:
/src/wx/HEAD/include/wx/defs.h: In function 'void wxDELETE(T*&)':
/src/wx/HEAD/include/wx/defs.h:634:22: warning: typedef 'TypeIsCompleteCheck' locally defined but not used [-Wunused-local-typedefs]
         typedef char TypeIsCompleteCheck[sizeof(T)];
                      ^
/src/wx/HEAD/include/wx/defs.h: In function 'void wxDELETEA(T*&)':
/src/wx/HEAD/include/wx/defs.h:647:22: warning: typedef 'TypeIsCompleteCheck' locally defined but not used [-Wunused-local-typedefs]
         typedef char TypeIsCompleteCheck[sizeof(T)];
                      ^
/src/wx/HEAD/include/wx/scopedptr.h: In destructor 'wxScopedPtr<T>::~wxScopedPtr()':
/src/wx/HEAD/include/wx/checkeddelete.h:33:22: warning: typedef 'complete' locally defined but not used [-Wunused-local-typedefs]
         typedef char complete[sizeof(*ptr)];                                  \
                      ^
/src/wx/HEAD/include/wx/scopedptr.h:46:22: note: in expansion of macro 'wxCHECKED_DELETE'
     ~wxScopedPtr() { wxCHECKED_DELETE(m_ptr); }
                      ^

and possibly more (but those are bad enough already as they are given hundreds of times).

The solution would be to either use conditionally-defined WX_ATTRIBUTE_UNUSED which would expand into __attribute__((unused)) for g++ (it seems to be supported since forever so probably no need to check for the version) and use it in all the declarations above. Or, if there is any problem with this, to disable the warning, possibly using the new g++ _Pragma to do it only temporarily in these functions.

This should be easy to do but I don't have time for this right now so just making a note to try to achieve clean build with 4.8 for 3.0 release. Of course, any help/patches welcome as usual.

Attachments (1)

suppress-unused-typedef.patch download (2.0 KB) - added by minoki 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by minoki

comment:1 Changed 7 years ago by minoki

  • Cc minorinoki@… added
  • Patch set

Attached a patch to suppress the warning, using __attribute__((unused)).

comment:2 Changed 7 years ago by vadz

Great, thanks for taking care of this!

comment:3 Changed 7 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [74272]) Add WX_ATTRIBUTE_UNUSED and use it for typedefs to avoid g++ 4.8 warnings.

g++ 4.8 warns about unused typedef's in local scope resulting in hundreds of
warnings when building wx, suppress them by using WX_ATTRIBUTE_UNUSED for
these typedefs.

Closes #15137.

Note: See TracTickets for help on using tickets.