Author Topic: compile issue with wx 3.1.6  (Read 11952 times)

Offline kipade

  • Multiple posting newcomer
  • *
  • Posts: 50
compile issue with wx 3.1.6
« on: September 19, 2021, 02:52:24 pm »
When I update my wx into latest 3.1.6 version, codeblocks could not be compiled any more, because a c++ issue:
Code
n file included from /usr/include/wx-3.1/wx/wx.h:24,
                 from /usr/include/wx-3.1/wx/wxprec.h:42,
                 from ../../../src/include/sdk_common.h:24,
                 from ../../../src/include/sdk_precomp.h:13:
/usr/include/wx-3.1/wx/event.h: In instantiation of 'constexpr auto wxPrivate::DoCast(void (C::*)(E&)) [with E = wxHtmlLinkEvent; C = CCManager]':
../../../src/sdk/ccmanager.cpp:290:22:   required from here
/usr/include/wx-3.1/wx/event.h:157:12: error: 'wxEvtHandler' is an inaccessible base of 'CCManager'
  157 |     return static_cast<void (wxEvtHandler::*)(E&)>(pmf);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

But, the CCManager DO is the child class of wxEvtHandler. How to fix this compile issue?
/usr/include/wx-3.1/wx/event.h:157:12: note:    in pointer to member function conversion


Offline AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 678
Re: compile issue with wx 3.1.6
« Reply #1 on: September 19, 2021, 03:14:39 pm »
Are you using the latest SVN trunc code?
If yes, when did you grab the code?
If not try the very latest CF SVN code as it has changes for 3.1.6 from a few weeks ago.

If the latest truck codes  does not help , then comi9ler are you using? Version and the URL you used to download it from?

When did you grab the 3.1.6 Github sources to do the build?


Offline kipade

  • Multiple posting newcomer
  • *
  • Posts: 50
Re: compile issue with wx 3.1.6
« Reply #2 on: September 19, 2021, 03:33:07 pm »
I think it should be.
I always keep it fresh from https://github.com/obfuscated/codeblocks_sf.git. and from its latest commit log, its equal as svn 12529.
and my OS is ArchLinux, gcc version 11.1.0
thanks
« Last Edit: September 19, 2021, 03:44:57 pm by kipade »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: compile issue with wx 3.1.6
« Reply #3 on: September 20, 2021, 12:11:58 pm »
Works OK with C::B trunk, wxWidgets head and MinGW 8.1 on MSW.

EDIT: may be related to this bug in GCC. Also related to this wxWidgets ticket, fixed 5 years ago.
« Last Edit: September 20, 2021, 04:31:11 pm by Miguel Gimenez »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: compile issue with wx 3.1.6
« Reply #4 on: September 20, 2021, 05:20:49 pm »
From https://www.gnu.org/software/gcc/gcc-11/changes.html

Quote
The default mode for C++ is now -std=gnu++17 instead of -std=gnu++14.

You might be having this new issue because of the default change.

I would try using "-std=gnu++14" to see if that fixes the issue.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline kipade

  • Multiple posting newcomer
  • *
  • Posts: 50
Re: compile issue with wx 3.1.6
« Reply #5 on: September 21, 2021, 01:09:06 am »
Yes, this option do really works for it. Thanks

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: compile issue with wx 3.1.6
« Reply #6 on: September 21, 2021, 11:55:37 am »
I have just created a ticket on wxWidgets bug tracker.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: compile issue with wx 3.1.6
« Reply #7 on: September 24, 2021, 03:56:11 pm »
@kipade, wxWidgets devs are asking for a quick check, can you do it?. I don't have GCC11.

https://trac.wxwidgets.org/ticket/19266

This is the code to compile:

Code
// This is a compilation-time-only test: just check that a class inheriting
// from wxEvtHandler non-publicly can use Bind() with its method, this used to
// result in compilation errors.
// Note that this test will work only on C++11 compilers, so we test this only
// for such compilers.
#if __cplusplus >= 201103
class HandlerNonPublic : protected wxEvtHandler
{
public:
    HandlerNonPublic()
    {
        Bind(wxEVT_IDLE, &HandlerNonPublic::OnIdle, this);
    }

    void OnIdle(wxIdleEvent&) { }
};
#endif // C++11

EDIT: You can use the attached minimal wxWidgets project, it includes the code above. It is a MSW project, but can be easily adapted to Linux.
« Last Edit: September 24, 2021, 05:41:32 pm by Miguel Gimenez »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: compile issue with wx 3.1.6
« Reply #8 on: September 24, 2021, 07:16:55 pm »
There is another question in the ticket about the output of this code:

Code
#include <iostream>

int main()
{
    std::cout << "__cplusplus= " << __cplusplus << std::endl;
    return (int)__cplusplus;
}

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: compile issue with wx 3.1.6
« Reply #9 on: October 04, 2021, 11:33:50 am »
The solution for this issue is Use Bind() instead of Connect(), as indicated in this wxWidgets ticket.

Following the ticket, documentation for Connect() has been updated to remark that it can be used only with methods of classes publicly inheriting from wxEvtHandler. CCManager derives privately from wxEvtHandler, so it should be modified to use Bind() or change visibility of wxEvtHandler.

I will try to make a patch this week using the first option.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: compile issue with wx 3.1.6
« Reply #10 on: October 06, 2021, 04:30:48 pm »
This is fixed in the trunk now, thanks!
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.