Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: kipade on September 19, 2021, 02:52:24 pm

Title: compile issue with wx 3.1.6
Post by: kipade 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

Title: Re: compile issue with wx 3.1.6
Post by: AndrewCot 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?

Title: Re: compile issue with wx 3.1.6
Post by: kipade 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
Title: Re: compile issue with wx 3.1.6
Post by: Miguel Gimenez 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 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60829) in GCC. Also related to this (http://trac.wxwidgets.org/ticket/17623) wxWidgets ticket, fixed 5 years ago.
Title: Re: compile issue with wx 3.1.6
Post by: stahta01 on September 20, 2021, 05:20:49 pm
From https://www.gnu.org/software/gcc/gcc-11/changes.html (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.
Title: Re: compile issue with wx 3.1.6
Post by: kipade on September 21, 2021, 01:09:06 am
Yes, this option do really works for it. Thanks
Title: Re: compile issue with wx 3.1.6
Post by: Miguel Gimenez on September 21, 2021, 11:55:37 am
I have just created a ticket (https://trac.wxwidgets.org/ticket/19266) on wxWidgets bug tracker.
Title: Re: compile issue with wx 3.1.6
Post by: Miguel Gimenez 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 (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.
Title: Re: compile issue with wx 3.1.6
Post by: Miguel Gimenez 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;
}
Title: Re: compile issue with wx 3.1.6
Post by: Miguel Gimenez 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 (https://trac.wxwidgets.org/ticket/19266).

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.
Title: Re: compile issue with wx 3.1.6
Post by: ollydbg on October 06, 2021, 04:30:48 pm
This is fixed in the trunk now, thanks!