Closed rbtcollins closed 2 years ago
@rbtcollins, thanks for the feedback. I don't understand what you are talking about. Could you explain it more clearly? Thanks!
I can try ;).
My development environment for this project is VS Code + The Visual Studio 2022 Community edition C++ Compiler toolchain, building using CMake + Ninja.
I'm building in C++17 mode- in CMakeLists.txt:
target_compile_features(lib_common PRIVATE cxx_std_17)
This causes the compiler (cl
)to receive the flag -std:c++17
on the command line, which enables C++ 17 semantics. When set the __cplusplus
macro value is 199711
.
Because of this I had to modify peglib.h
to make my parser compile. With the modification the parser seems to work fine - I have ~ 1MB of data, and it all gets processed and I get back the top level value as expected.
The change I made is trivial - just commenting out the __cplusplus version check at the top of peglib.h
.
@rbtcollins, thanks. I now fully understand your situation. :)
It's a simply problem with how to handle __cplusplus
in MSVC, and also a longstanding known issue. You can see more information here:
https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
The following article is helpful as well: https://discourse.cmake.org/t/set-cmake-cxx-standard-should-set-zc-cplusplus-for-msvc/1876
As the documents mention, you need to enable the /Zc:__cplusplus
option. Please see my CMakeLists.txt:
Hope this helps!
Even with the cl flag
-std:c++17
- which successfully builds the demo from README.mdI've commented it out in the code I'm using, but it would be nice if this was addressed upstream somehow.