Menu

Problems compiling against wxWidgets 3.0

Help
WoFo
2016-03-29
2016-06-02
  • WoFo

    WoFo - 2016-03-29

    Dear Experts,

    I'm trying to compile the examples against wxWidgets 3.0, and I am getting an error related to wx/log.h:

    from mathplot.cpp

    // This method updates the buffers m_trans_shape_xs/ys, and the precomputed bounding box.
    void mpMovableObject::ShapeUpdated()
    {
        // Just in case...
        if (m_shape_xs.size()!=m_shape_ys.size())
        {
            ::wxLogError(wxT("[mpMovableObject::ShapeUpdated] Error, m_shape_xs and m_shape_ys have different lengths!"));
    

    For the last line, the error message I get is:

    In file included from /home/wo/Desktop/install/wxMathPlot/wxMathPlot-0.1.2/mathplot.cpp:36:0:
    /home/wo/Desktop/install/wxMathPlot/wxMathPlot-0.1.2/mathplot.cpp: In member function 'void mpMovableObject::ShapeUpdated()':
    /usr/include/wx-3.0/wx/log.h:1361:5: error: expected id-expression before 'for'
         for ( bool loopvar = false;                                               \
         ^
    /usr/include/wx-3.0/wx/log.h:1367:5: note: in expansion of macro 'wxDO_LOG_IF_ENABLED_HELPER'
         wxDO_LOG_IF_ENABLED_HELPER(level, wxMAKE_UNIQUE_NAME(wxlogcheck))
         ^
    /usr/include/wx-3.0/wx/log.h:1374:20: note: in expansion of macro 'wxDO_LOG_IF_ENABLED'
     #define wxLogError wxDO_LOG_IF_ENABLED(Error)
                        ^
    /home/wo/Desktop/install/wxMathPlot/wxMathPlot-0.1.2/mathplot.cpp:2610:11: note: in expansion of macro 'wxLogError'
             ::wxLogError(wxT("[mpMovableObject::ShapeUpdated] Error, m_shape_xs and m_shape_ys have different lengths!"));
               ^
    /usr/include/wx-3.0/wx/log.h:1367:58: error: 'wxlogcheck2610' was not declared in this scope
         wxDO_LOG_IF_ENABLED_HELPER(level, wxMAKE_UNIQUE_NAME(wxlogcheck))
    (..., lots of consecutive errors to follow)
    

    from wx/log.h (the error related code starts after the #else)

    #ifdef __VISUALC6__
    #define wxDO_LOG_IF_ENABLED(level)                                            \
        if ( !wxLog::IsLevelEnabled(wxLOG_##level, wxLOG_COMPONENT) )             \
        {}                                                                        \
        else                                                                      \
            wxDO_LOG(level)
    #else
    #define wxDO_LOG_IF_ENABLED_HELPER(level, loopvar)                            \
        for ( bool loopvar = false;                                               \
              !loopvar && wxLog::IsLevelEnabled(wxLOG_##level, wxLOG_COMPONENT);  \
              loopvar = true )                                                    \
            wxDO_LOG(level)
    
    #define wxDO_LOG_IF_ENABLED(level)                                            \
        wxDO_LOG_IF_ENABLED_HELPER(level, wxMAKE_UNIQUE_NAME(wxlogcheck))
    #endif
    

    Seems it affects all calls to ::wxLogError...
    When commenting them out, the code compiles.

    I'm using the CodeLite IDE 9.1.0 and g++5 on Xubuntu 15.10. I created a project containing mathplot.h, mathplot.cpp and any one of the 3 examples (./samples/mp{1,2,3}.cpp).

    Any suggestions for a real fix?

    Thanks for advice!

     

    Last edit: WoFo 2016-03-31
  • Alex Hirzel

    Alex Hirzel - 2016-06-02

    In mathplot.cpp, change all references from "::wxLogError" to "wxLogError". This is because wxLogError is a macro rather than a function.

     

Log in to post a comment.