commschamp/comms

Missing member function of `comms`

bearbattle opened this issue · 5 comments

Hello!

When I compile my project with comms as a submodule, this error occurs:

~/comms/install/include/comms/protocol/MsgSizeLayer.h: In member function ‘comms::ErrorStatus comms::protocol::MsgSizeLayer<TField, TNextLayer, TOptions>::writeInternalNoLength(comms::protocol::MsgSizeLayer<TField, TNextLayer, TOptions>::Field&, const TMsg&, TIter&, std::size_t, TWriter&&) const’:
~/comms/install/include/comms/protocol/MsgSizeLayer.h:467:21: error: ‘isMessageBase’ is not a member of ‘comms’

Conent of comms/protocol/MsgSizeLayer.h:

image

My CMakeList.txt section:

include(${PROJECT_SOURCE_DIR}/library/comms/cmake/CC_CommsExternal.cmake)
set(cc_comms_install_dir ${PROJECT_BINARY_DIR}/comms/install)
cc_comms_build_during_config(
        SRC_DIR ${PROJECT_SOURCE_DIR}/library/comms
        CMAKE_ARGS
        TAG v5.0.1
        -DCMAKE_INSTALL_PREFIX=${cc_comms_install_dir}
        -DCC_COMMS_BUILD_UNIT_TESTS=OFF
)
list(APPEND CMAKE_PREFIX_PATH ${cc_comms_install_dir})
find_package(LibComms NO_MODULE REQUIRED)

I was compiling with tag v5.0.1.

This function is declared in comms/install/include/comms/MessageBase.h, so maybe this is an unintended mistake. After adding the #include "comms/MessageBase.h" line to comms/protocol/MsgSizeLayer.h, the error seems to disappear.

So the patch can be applied quickly, hope you can fix this soon!

Hi @bearbattle,
Thanks for the report. Looks like the "isMessageBase()" function is referenced in several other places as well without proper include. The "develop" branch should contain the fix. If no other problems are discovered, the correction release will be out soon.

Hi @arobenko ,
When compiling this with MSVC cl.exe 19.16.27048, it gave me this error:

warning C4003: not enough arguments for function-like macro invocation 'min'

The error would cause ~\comms\install\include\comms\options.h:76 with other errors.

A solution is adding #define NOMINMAX macro to prevent 'dump' MSVC compiler from recognize std::numeric_limits<~>::min() as the min(a, b) macro.

Ref: numeric_limits::max() not recognized

As followed from this discussion, there are two ways around:

  1. #define NOMINMAX - it disables min(a, b) and max(a, b) macros, but std::min(a,b) and std::max(a, b) from are working fine
  2. #ifdef min
    #undef min
    #undef max
    #endif
    If it is placed in right place it works.

Hi @bearbattle,
It is a bad practice for the library to impose compilation restrictions on the client code. It's the opposite that needs to apply, i.e. trying to adapt to the used compilation options. That's why I disable some warnings in some places and restore original state at the end of the "problematic" section. I cannot silently change the client code controlling defines in my headers. It may have nasty, unintended, difficult to debug consequences.

You've listed the solution yourself. If you don't use the Microsoft specific macros in you code, just use global "/D NOMINMAX" compilation option in your project. If you do use them, then you just do #define NOMINMAX before any windows specific includes (like #include <windows.h>) in the problematic file.

The bottom line, I'm not going to change anything in the library in this regard. Won't fix.

By the way I just noticed that I did the include fix on the "master" branch by mistake, rather than on the develop. I'll do the "v5.0.2" correction release soon to keep the "master" branch pointing to the latest release.

Original report is fixed in v5.0.2 release.