Compile error building wxWidgets under msys2 Topic is solved

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
RobertSimpson
Experienced Solver
Experienced Solver
Posts: 88
Joined: Sat Oct 18, 2008 8:32 pm

Compile error building wxWidgets under msys2

Post by RobertSimpson »

Just tried compiling under msys2 (not msys) using the instructions here: https://wiki.wxwidgets.org/Eclipse,_CDT ... _wxWidgets (The only thing modified is the directory names as they are slightly different with msys2 compared with the original MinGW/msys).

Everything was freshly installed. Running on windows 10.

gcc version 8.2.0 (Rev3, Built by MSYS2 project)

Code: Select all

/wxWidgets-3.1.1/build-release/bk-deps g++ -c -o basedll_any.o  -D__WXMSW__     -DWXBUILDING -I/wxWidgets-3.1.1/build-release/src/tiff/libtiff -I../src/tiff/libtiff -I../src/jpeg -I../src/png  -I../src/regex  -DwxUSE_GUI=0 -DWXMAKINGDLL_BASE -DwxUSE_BASE=1  -Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual -D_FILE_OFFSET_BITS=64 -I/wxWidgets-3.1.1/build-release/lib/wx/include/msw-unicode-3.1 -I../include -O2  ../src/common/any.cpp
/wxWidgets-3.1.1/build-release/bk-deps g++ -c -o basedll_appbase.o  -D__WXMSW__     -DWXBUILDING -I/wxWidgets-3.1.1/build-release/src/tiff/libtiff -I../src/tiff/libtiff -I../src/jpeg -I../src/png  -I../src/regex  -DwxUSE_GUI=0 -DWXMAKINGDLL_BASE -DwxUSE_BASE=1  -Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual -D_FILE_OFFSET_BITS=64 -I/wxWidgets-3.1.1/build-release/lib/wx/include/msw-unicode-3.1 -I../include -O2  ../src/common/appbase.cpp
In file included from ../include/wx/msw/debughlp.h:35,
                 from ../src/common/appbase.cpp:105:
../include/wx/msw/private.h: In static member function 'static void* AutoHANDLE<INVALID_VALUE>::InvalidHandle()':
../include/wx/msw/private.h:148:49: error: invalid static_cast from type 'long long unsigned int' to type 'HANDLE' {aka 'void*'}
         return static_cast<HANDLE>(INVALID_VALUE);
                                                 ^
make: *** [Makefile:26531: basedll_appbase.o] Error 1
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 469
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Compile error building wxWidgets under msys2

Post by New Pagodi »

I just tried it and got the same error. However the latest version from git does compile.

I don't remember anyone reporting the error with mingw/gcc8.2 so I don't know when or how this problem was fixed.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 550
Joined: Fri Nov 03, 2006 2:00 pm

Re: Compile error building wxWidgets under msys2

Post by stahta01 »

Possible fix; not sure it is the whole fix or not.

Code: Select all

Revision: 424f64f27d94f83ed946ebfcf9b9543c828f9f25
Author: Vadim Zeitlin <[email protected]>
Date: 5/27/2018 4:56:05 PM
Message:
Fix invalid cast in wxMSW AutoHANDLE::InvalidHandle()

Somehow this compiled with the previous gcc versions (as well as MSVS),
but a static_cast from an integer wxUIntPtr type to a pointer HANDLE
type is obviously invalid and a reinterpret_cast is needed here.

This fixes compilation with g++ 8.
----
Modified: include/wx/msw/private.h

Code: Select all

diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h
index f833a58a0f..1e4d0f8fcd 100644
--- a/include/wx/msw/private.h
+++ b/include/wx/msw/private.h
@@ -145,7 +145,7 @@ protected:
     // implicitly convertible to HANDLE, which is a pointer.
     static HANDLE InvalidHandle()
     {
-        return static_cast<HANDLE>(INVALID_VALUE);
+        return reinterpret_cast<HANDLE>(INVALID_VALUE);
     }
 
     void DoClose()
Tim S.
RobertSimpson
Experienced Solver
Experienced Solver
Posts: 88
Joined: Sat Oct 18, 2008 8:32 pm

Re: Compile error building wxWidgets under msys2

Post by RobertSimpson »

Thanks. That fixes it. No other errors.

Rob.
Post Reply