wxWidgets headers and compiler warnings

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
alys666
I live to help wx-kind
I live to help wx-kind
Posts: 199
Joined: Tue Oct 18, 2016 2:31 pm

wxWidgets headers and compiler warnings

Post by alys666 » Fri Apr 26, 2019 4:58 pm

Hi!
Some people like to switch all(reasonable) compiler warnings on,.. me too.
but if I use warnings:
-Wall -Wextra -pedantic -pedantic-errors -Wundef -Wfloat-equal -Wunreachable-code -Wmissing-include-dirs -Wswitch-default...
this is invocation string:
clang-6.0 -c -g -std=c++11 -pipe -pthread -Wall -Wextra -pedantic -pedantic-errors -Wundef -Wfloat-equal -Wunreachable-code -Wmissing-include-dirs -Wswitch-default -Wpointer-arith -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -I/usr/lib/llvm-6.0/include -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 /home......./main.cpp -o ./__CONFIG__/__temp.o
headers give some warnings kinda: (float equality)
/usr/include/wx-3.0/wx/math.h:126:63: warning: comparing floating point with == or != is unsafe [-Wfloat-equal]
inline bool wxIsSameDouble(double x, double y) { return x == y; }
or
/usr/include/wx-3.0/wx/any.h:336:5: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression]
WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl<T>)
or
/usr/include/wx-3.0/wx/mousestate.h: In member function bool wxMouseState::ButtonIsDown(wxMouseButton) const:
/usr/include/wx-3.0/wx/mousestate.h:79:16: warning: switch missing default case [-Wswitch-default]
switch ( but )
question or proposal :
may be in future development of wxWidgets have this warnings on and somehow correct the code?
thanks. Alex
ubuntu 16.04, wxWidgets 3.0.4

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2025
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxWidgets headers and compiler warnings

Post by PB » Fri Apr 26, 2019 5:10 pm

IMO, this level of warning is best to be turned off for the external libraries and a decent compiler should easily allow that. I do not use Clang but it Google tells me it has -isystem option for that.

Anyway, if you believe the warnings are correct, you can submit a PR (or patch) fixing them. However, I believe that this should not be done for 3.0 branch where only bugs are fixed and all the new development goes on in 3.1 branch. I would not be surprised if some of the issues have already been fixed there...

alys666
I live to help wx-kind
I live to help wx-kind
Posts: 199
Joined: Tue Oct 18, 2016 2:31 pm

Re: wxWidgets headers and compiler warnings

Post by alys666 » Fri Apr 26, 2019 5:30 pm

it's only 3 kinds of warnings i see in last 3.0.
- float equality/inequality : for me it's quite significant warning because here could be a bug, since float representation accuracy. or may be compiler makes correct code for this(but why he warns me?)
so better to have -Wfloat-equal

-missed default case: helps to find missed enumeration members in switch.
better to have - -Wswitch-default

-Wpotentially-evaluated-expression - do not know what this warning means...but for me any warning is a reason to think :)
Alex
ubuntu 16.04, wxWidgets 3.0.4

Post Reply