Closed piotrek-szczygiel closed 5 years ago
I tried C++17 with GCC 9.2 here where I could not reproduce the compiler error using libcluon v0.0.126 on a minimal example: https://wandbox.org/permlink/g3VbL5v2aYWZrHvQ
We have AppVeyor with VS2017/19.16.27032.1 running using C++14: https://ci.appveyor.com/project/chrberger/libcluon; could you try a different C++ standard to provide more details about this?
I just tested Visual Studio 2019/C++17 on AppVeyor (https://ci.appveyor.com/project/chrberger/libcluon#L837) using this commit (https://github.com/chrberger/libcluon/commit/959e99dbf004e3a508ea3bfcac3ffbd456bfbe21) which was compiled and tested successfully.
There is a problem. It collides with windows's NO_ERROR macro Same goes for min/max
I'm getting a similar error with MinGW 7.3.0 (tried standards 14 and 17)
Minimal example:
#include <cluon/cluon-complete.hpp>
int main() {
return 0;
}
The compilation fails with:
.../cluon/cluon-complete.hpp: In member function 'std::pair<std::vector<cluon::MetaMessage>, cluon::MessageParser::MessageParserErrorCodes> cluon::MessageParser::parse(const string&)':
.../cluon/cluon-complete.hpp:9806:76: error: expected unqualified-id before numeric constant
retVal = {listOfMetaMessages, MessageParserErrorCodes::NO_ERROR};
^
I have prepared the changes related to NO_ERROR in MessageParser.cpp (https://github.com/chrberger/libcluon/commit/ac95c6d4989be8d6e894411869c7b6a38c1ed3c0).
Before I will make a new release, may I ask you, @barulicm, to check the header-only file that I put here into the online C++ compiler Wandbox: https://wandbox.org/permlink/0tPXbiAtmGVdp4Kx if the error has been resolved for your minimal example with MinGW?
That seems to have addressed the NO_ERROR issue. Unfortunately, there are now errors like the following for every use of ntohll
and htonll
In file included from C:\Users\matth\CLionProjects\cluontest\main.cpp:1:0:
...\cluon-complete.hpp: In member function 'void cluon::FromLCMVisitor::decodeFrom(std::istream&)':
...\cluon-complete.hpp:5631:20: error: 'ntohll' was not declared in this scope
#define be64toh(x) ntohll(x)
^
...\cluon-complete.hpp:11617:39: note: in expansion of macro 'be64toh'
m_expectedHash = static_cast<int64_t>(be64toh(m_expectedHash));
^
...\cluon-complete.hpp:5631:20: note: suggested alternative: 'ntohl'
#define be64toh(x) ntohll(x)
^
...\cluon-complete.hpp:11617:39: note: in expansion of macro 'be64toh'
m_expectedHash = static_cast<int64_t>(be64toh(m_expectedHash));
^
I made another change to lines 5,620 - 5,625 here: https://wandbox.org/permlink/dpKAs1BN6MBq5b8B
Could you try again if the missing symbols are now defined on your platform?
That new version built successfully. I was also able to build and run the time stamping and TCP server examples without any problems. Looks fixed to me!
I may have spoken too soon. I switched my tool chain to Visual Studio (2019), just to see, and I got the following errors on the bare bones example.
main.cpp
...\cluon-complete.hpp(14499): warning C4003: not enough arguments for function-like macro invocation 'max'
...\cluon-complete.hpp(14499): error C2589: '(': illegal token on right side of '::'
...\cluon-complete.hpp(14499): error C2062: type 'unknown-type' unexpected
...\cluon-complete.hpp(14499): error C2059: syntax error: ')'
...\cluon-complete.hpp(14500): warning C4003: not enough arguments for function-like macro invocation 'min'
...\cluon-complete.hpp(14500): error C2589: '(': illegal token on right side of '::'
...\cluon-complete.hpp(14500): error C2062: type 'unknown-type' unexpected
...\cluon-complete.hpp(14500): error C2059: syntax error: ')'
...\cluon-complete.hpp(14502): error C2589: '(': illegal token on right side of '::'
...\cluon-complete.hpp(14502): error C2062: type 'unknown-type' unexpected
...\cluon-complete.hpp(14502): error C2059: syntax error: ')'
...\cluon-complete.hpp(14503): error C2589: '(': illegal token on right side of '::'
...\cluon-complete.hpp(14503): error C2062: type 'unknown-type' unexpected
...\cluon-complete.hpp(14503): error C2059: syntax error: ')'
Thanks for testing, @barulicm ; may I ask you to check this version (https://github.com/chrberger/libcluon/commit/778f46c4cb507d854ffff62d9a3ced110a36ce53) where I changed the min/max part: https://wandbox.org/permlink/FDM8LZ4HHCMYD5Ag
Almost worked. I had to change lines 14499 and 14500 from:
int64_t smallestSampleTimePoint = (std::numeric_limits<int64_t>::max());
int64_t largestSampleTimePoint = (std::numeric_limits<int64_t>::min());
to:
int64_t smallestSampleTimePoint = (std::numeric_limits<int64_t>::max)();
int64_t largestSampleTimePoint = (std::numeric_limits<int64_t>::min)();
With that small change, it worked for both mingw and visual studio.
@barulicm, thanks for your feedback; I am happy that it does compile now for you. I will now prepare the next official release.
@piotrek-szczygiel: If you want to proceed, you can find the latest version including all patches here: https://wandbox.org/permlink/b6WpI4Y8fmuhWxdn
I cannot get it to compile using Visual Studio 2019 with C++17 standard enabled.
Compiler messages:
Looks like it fails while parsing
MessageParserErrorCodes::NO_ERROR
for some reason.Some code context: