Deprecated warning with gcc 5.2

249 views
Skip to first unread message

Igor Korot

unread,
May 1, 2016, 6:09:12 PM5/1/16
to wx-dev
Hi, ALL,
I recently switched to gcc-5.2 since I needed C++11 compiler from 4.8.5.

Trying to compile the library I started seeing following:

warning: 'virtual void wxWindowBase::SetInitialBestSize(const
wxSize&)' is deprecated: use SetInitialSize() instead.
[-Wdeprecated-declarations]

which I didn't see before.

This is with wx-3.1 as well as with recent HEAD (couple of days ago).

The log contains a lot of those warnings.

Here is the compilation command for one file which produces the warning:

/home/igor/wxFork/buildGTK2/bk-deps g++ -c -o gldll_glx11.o
-I./.pch/wxprec_gldll -D__WXGTK__ -DWXBUILDING
-I../src/regex -DWXUSINGDLL -DWXMAKINGDLL_GL -fPIC -DPIC -Wall
-Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual
-D_FILE_OFFSET_BITS=64
-I/home/igor/wxFork/buildGTK2/lib/wx/include/gtk2-unicode-3.1
-I../include -pthread -I/usr/include/gtk-2.0
-I/usr/lib64/gtk-2.0/include -I/usr/include/pango-1.0
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1
-I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0
-I/usr/include/libpng16 -I/usr/include/pango-1.0
-I/usr/include/harfbuzz -I/usr/include/pango-1.0
-I/usr/include/freetype2 -I/usr/include/glib-2.0
-I/usr/lib64/glib-2.0/include -pthread -I/usr/include/gstreamer-1.0
-I/usr/lib64/gstreamer-1.0/include -I/usr/include/glib-2.0
-I/usr/lib64/glib-2.0/include -DWX_PRECOMP -pthread -ggdb -O0 -pthread
-I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -pthread
-I/usr/include/gtk-unix-print-2.0 -I/usr/include/gtk-2.0
-I/usr/lib64/gtk-2.0/include -I/usr/include/pango-1.0
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1
-I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0
-I/usr/include/libpng16 -I/usr/include/pango-1.0
-I/usr/include/harfbuzz -I/usr/include/pango-1.0
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
-I/usr/include/freetype2 -fvisibility=hidden
-fvisibility-inlines-hidden ../src/unix/glx11.cpp


Thank you.

Vadim Zeitlin

unread,
May 1, 2016, 6:16:08 PM5/1/16
to wx-...@googlegroups.com
On Sun, 1 May 2016 18:09:11 -0400 Igor Korot wrote:

IK> Trying to compile the library I started seeing following:
IK>
IK> warning: 'virtual void wxWindowBase::SetInitialBestSize(const
IK> wxSize&)' is deprecated: use SetInitialSize() instead.
IK> [-Wdeprecated-declarations]
IK>
IK> which I didn't see before.

Surprising because this issue has been discussed half a dozen times here,
on wx-users and in Trac since more than a year. Please check the archives
(and no, there is still no solution other than disabling deprecation
warnings).

Regards,
VZ

Iwbnwif Yiw

unread,
May 1, 2016, 6:23:53 PM5/1/16
to wx-dev
This is a workaround that was suggested previously.

For me it hugely improves the situation with wxWidgets 3.1.

--- a/include/wx/window.h 
+++ b/include/wx/window.h 
@@ -1695,7 +1695,9 @@ protected: 

     wxDEPRECATED_MSG("use SetInitialSize() instead.") 
     void SetBestSize(const wxSize& size); 
+#if !wxCHECK_GCC_VERSION(5, 0) 
     wxDEPRECATED_MSG("use SetInitialSize() instead.") 
+#endif 
     virtual void SetInitialBestSize(const wxSize& size); 

Igor Korot

unread,
May 1, 2016, 7:07:22 PM5/1/16
to wx-dev
Vadim,
It is surprising especially as I said I didn't see them with 4.8, and
the command
used to compile does not have "no-deprecated-declarations".

Maybe with 5.2 is something different?

Now I tried to compile the code with "--with-gtk=2".

Thank you.

>
> Regards,
> VZ

Iwbnwif Yiw

unread,
May 2, 2016, 6:28:51 AM5/2/16
to wx-dev
On Monday, May 2, 2016 at 12:07:22 AM UTC+1, Igor Korot wrote:
It is surprising especially as I said I didn't see them with 4.8, and
the command
used to compile does not have "no-deprecated-declarations".

Maybe with 5.2 is something different?

Igor, 

The reason you are seeing it with 5.2 and not 4.8 is because it is a compiler bug, see:


And to be quite frank it is a PITA because although the patch (not mine) I posted earlier helps a lot with building wxWidgets, there are plenty of other situations where you get hundreds of deprecated warnings if you try to use certain classes. 

For instance, I am facing exactly the same problem now with wxDataViewCustomRendererBase where ::Activate and ::LeftClick are #defined wxDEPRECATED_BUT_USED_INTERNALLY_INLINE (which resolves to wxDEPRECATED in user apps). Even though I don't attempt to override these methods I still get a screen full of deprecated warnings.

I think that the only options are:
  1. Disable deprecated warnings (as VZ suggests).
  2. Use a newer version of the compiler (I haven't tested but presumably 5.3 has this fix see https://gcc.gnu.org/bugzilla/buglist.cgi?bug_status=RESOLVED&resolution=FIXED&target_milestone=5.3).
  3. Apply the patch https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/cp/decl2.c?r1=226908&r2=226907&pathrev=226908 to your current compiler version and rebuild.
  4. Hack the wxWidgets files to remove the deprecation tags.
  5. Put up with a large number of warnings and search through them in case there is something you really need to worry about.
Personally, except for #2, I am not sure that any of these is particularly pleasant. Unfortunately for me, I am a bit stuck because I am using TDM-GCC and it isn't updated yet. Probably time to change compilers!!

IY.

Scott Furry

unread,
May 3, 2016, 8:07:49 AM5/3/16
to wx-dev
I can confirm #2 at least for Arch Linux.
I have been using the -Wno-deprecated-declarations flag when compiling to silence the messages in my own projects.
After reading this thread, I had to try compiling without the flag since my g++ is version 5.3.0.

Surprise....it worked! And no overflowing warning messages.
Maybe there is hope...

Reply all
Reply to author
Forward
0 new messages