Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpp_redis does not compile with MSVC in conformance mode or with C++20 #122

Open
chriss5 opened this issue Oct 27, 2023 · 1 comment
Open

Comments

@chriss5
Copy link

chriss5 commented Oct 27, 2023

When building cpp_redis with Microsoft Visual Studio and switching the permissive mode off (=conformance mode on) or switching the language standard to C++20 (what implicitly enabled the conformacne mode), cpp_redis no longer compiles due to an error in optional.hpp when explanding __CPP_REDIS_LOG(1, "value_or(U&& v)\n") to cpp_redis::1(...)
Error C2589 'constant': illegal token on right side of '::'

The reason is that MSVC by default sets the __cplusplus makro to 199711L even for newer language standards.

The solution is to either set an additional compiler option in the visual studio project: /Zc:__cplusplus or to update the line
#if __cplusplus >= 201703L in optional.hpp to also check for _MSVC_LANG

@chriss5
Copy link
Author

chriss5 commented Oct 27, 2023

I had forgotten to add the referene for MSVC's behavior and the compiler option: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant