Complilation error on Windows with MSYS2 MINGW64 (Issue #26703)

16 views
Skip to first unread message

FredCL13

unread,
5:58 AM (17 hours ago) 5:58 AM
to wx-...@googlegroups.com, Subscribed
FredCL13 created an issue (wxWidgets/wxWidgets#26703)

Build System Used

I build wxWidgets and/or my application using:

[3.6.3-3] MSYS2 MINGW64
[15.1.0-5] mingw-w64-ucrt-x86_64-gcc

configure is luanched as :
../configure CFLAGS="-static" --with-msw --enable-monolithic --disable-shared
and after make

config.log

Description

When compiling i encoutered two errors:
1 - In file include/wx/defs.h in function inline wxUIntPtr wxPtrToUInt(const void p)
../include/wx/defs.h:956:12: error: cast from 'const void
' to 'wxUIntPtr' {aka 'long unsigned int'} loses precision [-fpermissive]
956 | return reinterpret_cast(p);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:20110: monolib_any.o] Error 1

To solve the issue I 've patched the line :
return reinterpret_cast(p);
by:
#if defined(GNUC) && defined(MINGW64)
// GCC MinGW64 rejects reinterpret_cast(p)
// We use uintptr_t instead, which provides a standard and safe conversion
return static_cast(reinterpret_cast<uintptr_t>(p));
#else
// Original code for MSVC, ICC, Clang, Linux, macOS, etc.
return reinterpret_cast(p);
#endif

2 - In file src/msw/glcanvas.cpp in function
../src/msw/glcanvas.cpp:630:25: error: cast from 'void (*)()' to 'wxIntPtr' {aka 'long int'} loses precision [-fpermissive]
630 | const auto ptrVal = reinterpret_cast(ptr);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:34648: gllib_msw_glcanvas.o] Error 1

To solve the issue I've patched the line :
const auto ptrVal = reinterpret_cast(ptr);
by:
#if defined(GNUC) && defined(MINGW64)
// GCC MinGW64 rejects reinterpret_cast(ptr)
// We use intptr_t instead, which provides a standard and safe conversion
const auto ptrVal = static_cast(reinterpret_cast<intptr_t>(ptr));
#else
// Original code for MSVC, ICC, Clang, GCC Linux, etc.
const auto ptrVal = reinterpret_cast(ptr);
#endif

Platform and version information

  • wxWidgets version : 3.3.3
  • wxWidgets port wxMSW
  • Windows 11 25H2 build 26200.8875 pack 1000.26100.334.0
  • Compiler mingw-w64-ucrt-x86_64-gcc 15.1.0-5

for information I don't encoutered the problem when I've compiled on Linux (standard compilation ../configure + make)


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26703@github.com>

FredCL13

unread,
6:22 AM (16 hours ago) 6:22 AM
to wx-...@googlegroups.com, Subscribed
FredCL13 left a comment (wxWidgets/wxWidgets#26703)

It seem that Github remove some characters in my post:
the patches start by :

#if defined(__GNUC__) && defined(__MINGW64__)

So first patch for defs.h

#if defined(__GNUC__) && defined(__MINGW64__)
    // GCC MinGW64 rejects reinterpret_cast<wxIntPtr>(p)
    // We use uintptr_t instead, which provides a standard and safe conversion
    return static_cast<wxUIntPtr>(reinterpret_cast<uintptr_t>(p));
#else
    // Original code for MSVC, ICC, Clang, Linux, macOS, etc.
    return reinterpret_cast<wxUIntPtr>(p);
#endif

Second patch for glcanvas.cpp

#if defined(__GNUC__) && defined(__MINGW64__)
    // GCC MinGW64 rejects reinterpret_cast<wxIntPtr>(ptr)
    // We use intptr_t instead, which provides a standard and safe conversion
    const auto ptrVal = static_cast<wxIntPtr>(reinterpret_cast<intptr_t>(ptr));
#else
    // Original code for MSVC, ICC, Clang, GCC Linux, etc.
    const auto ptrVal = reinterpret_cast<wxIntPtr>(ptr);
#endif

I encoutered also some warning:
../src/generic/filectrlg.cpp: In member function 'virtual void wxFileListCtrl::UpdateItem(const wxListItem&)':
../src/generic/filectrlg.cpp:469:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
469 | wxFileData fd = (wxFileData)GetItemData(item);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/generic/filectrlg.cpp: In member function 'void wxFileListCtrl::FreeItemData(wxListItem&)':
../src/generic/filectrlg.cpp:711:26: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
711 | wxFileData fd = (wxFileData)item.m_data;
| ^~~~~~~~~~~~~~~~~~~~~~~~
../src/generic/filectrlg.cpp: In member function 'void wxFileListCtrl::OnListEndLabelEdit(wxListEvent&)':
../src/generic/filectrlg.cpp:744:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
744 | wxFileData fd = (wxFileData)event.m_item.m_data;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../src/stc/stc.cpp: In member function 'void* wxStyledTextCtrl::GetDirectFunction() const':
../src/stc/stc.cpp:2020:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
2020 | return (void*)SendMsg(SCI_GETDIRECTFUNCTION);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/stc/stc.cpp: In member function 'void* wxStyledTextCtrl::GetDirectPointer() const':
../src/stc/stc.cpp:2026:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
2026 | return (void*)SendMsg(SCI_GETDIRECTPOINTER);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/stc/stc.cpp: In member function 'void* wxStyledTextCtrl::GetDocPointer()':
../src/stc/stc.cpp:3168:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
3168 | return (void*)SendMsg(SCI_GETDOCPOINTER);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/stc/stc.cpp: In member function 'void* wxStyledTextCtrl::CreateDocument()':
../src/stc/stc.cpp:3294:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
3294 | return (void*)SendMsg(SCI_CREATEDOCUMENT);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/stc/stc.cpp: In member function 'const char* wxStyledTextCtrl::GetCharacterPointer() const':
../src/stc/stc.cpp:3998:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
3998 | return (const char*)SendMsg(SCI_GETCHARACTERPOINTER, 0, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/stc/stc.cpp: In member function 'const char* wxStyledTextCtrl::GetRangePointer(int, int) const':
../src/stc/stc.cpp:4005:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
4005 | return (const char*)SendMsg(SCI_GETRANGEPOINTER, position, rangeLength);


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26703/5002041756@github.com>

PB

unread,
7:58 AM (15 hours ago) 7:58 AM
to wx-...@googlegroups.com, Subscribed
PBfordev left a comment (wxWidgets/wxWidgets#26703)

wxWidgets 3.3.3 provides binaries for GCC v14.2 and v16.1 but not v15.

I wonder if this is GCC-version specific; wxWidgets 3.3.2 had binaries for GCC 15.2 and wxPtrToUInt() does not seem to have changed since...


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26703/5003031887@github.com>

FredCL13

unread,
9:02 AM (14 hours ago) 9:02 AM
to wx-...@googlegroups.com, Subscribed

Closed #26703 as completed.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/26703/issue_event/28122548131@github.com>

FredCL13

unread,
9:02 AM (14 hours ago) 9:02 AM
to wx-...@googlegroups.com, Subscribed
FredCL13 left a comment (wxWidgets/wxWidgets#26703)

It seems that the issue was caused by my antivirus during the configure step.
After disabling the antivirus, deleting the generated files, and running configure and make again, everything worked correctly.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26703/5003556169@github.com>

Reply all
Reply to author
Forward
0 new messages