billvaglienti / ProtoGen

Communications protocol generation software
MIT License
30 stars 16 forks source link

Error building protogen... #96

Closed knollpoi closed 4 years ago

knollpoi commented 4 years ago

See the compiler output below. Is this a known issue compiling with g++?

g++ -I. -I./ProtoGenTestCPP -I./ProtoGenInstall -I./ProtoGenTest -I./Novatel -I./.git -I./.git/logs -I./.git/logs/refs -I./.git/logs/refs/remotes -I./.git/logs/refs/remotes/origin -I./.git/logs/refs/heads -I./.git/info -I./.git/objects -I./.git/objects/info -I./.git/objects/pack -I./.git/branches -I./.git/refs -I./.git/refs/remotes -I./.git/refs/remotes/origin -I./.git/refs/tags -I./.git/refs/heads -I./.git/hooks -I./tinyxml -I./prebuiltSources -MMD -MP --std=c++17 -c protocolbitfield.cpp -o protocolbitfield.cpp.o protocolbitfield.cpp: In static member function ‘static std::cxx11::string ProtocolBitfield::getInnerDecodeString(const string&, const string&, int, int)’: protocolbitfield.cpp:302:96: error: ‘std::basic_ostream::ostream_type {aka class std::basic_ostream}’ has no member named ‘str’; did you mean ‘setf’? mask = " & 0x" + toUpper((std::stringstream() << std::hex << maxvalueoffield(numbits)).str()); ^~~ setf protocolbitfield.cpp: In static member function ‘static std::cxx11::string ProtocolBitfield::getComplexDecodeString(const string&, const string&, const string&, const string&, int, int)’: protocolbitfield.cpp:353:112: error: ‘std::basic_ostream::ostream_type {aka class std::basic_ostream}’ has no member named ‘str’; did you mean ‘setf’? std::string mask = " & 0x" + toUpper((std::stringstream() << std::hex << maxvalueoffield(leadingbits)).str()); ^~~ setf Makefile:20: recipe for target 'protocolbitfield.cpp.o' failed make: *** [protocolbitfield.cpp.o] Error 1

billvaglienti commented 4 years ago

I have similar errors when compiling under mingw8.1. According to the intertubes this is a known bug in gcc 8. The protogen code compiles cleanly under both clang and msvc.

billvaglienti commented 4 years ago

I just realized your error did not occur in compiling ProtoGen, but in the code output by ProtoGen (the test app in this case). So my comment above is bogus.

Again I can reproduce this error using minGw. It also appears to be a compiler problem specific to gcc. However there may be a workaround that I can implement.

billvaglienti commented 4 years ago

This post discusses the problem:

https://stackoverflow.com/questions/27391205/can-a-temporary-stringstream-object-be-used

The solution proposed in that post does work (namely static_cast to the correct type). I'll update ProtoGen to output the cast.

billvaglienti commented 4 years ago

The most recent commit (version 3.1.d) generates code that is compatible with GCC (as well as MSVC).