-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
warning C4706: assignment within conditional expression #295
Comments
I understand the warnings, but they seem to be uncritical and rather pedantic. A solution would be to either restructure the code by moving the assignment out of the conditional and make it less readable or to add |
Just to better understand MSVC at warning level 4: Would if (keep and (not callback or ((keep = callback(depth++, parse_event_t::object_start, result))) != 0)) fix this issue? |
Yes that fixes the issue. It could be rewritten I do not think it makes it any less clear, (I personally find that line with increment depth in the if a bit confusing to begin with. (But I am not a super experienced coder). ) For a easy fix you could just add: #ifdef _MSC_VER #ifdef _MSC_VER There is already some code that ignores specific warnings for clang. But its really up to you, as you said its not a critical problem. Just requires a tiny bit more work for someone integrating it. Awesome library btw, easy to use and great features. |
Ok. I think adding some Thanks for reporting! For a MSVC beginner - can you tell me how to compile a CMake project with this level of warnings? Added: https://msdn.microsoft.com/en-us/library/7hw7c1he%28v=vs.80%29.aspx |
Sorry to say I do not use CMake nor know how. I just included the source file in my visual studio project. That being said Warning level 4 is /W4 or even better EnableAllWarnings is /Wall. |
Thanks! I shall add this to the AppVeyor build to see what else MSVC is warning about. |
I ran an AppVeyor build with There are two error types: C4706 (assignment within conditional expression) and C4710 (function not inlined). We can ignore C4710. The remaining warnings are:
The two cases can be fixed with additional parenthesis and |
@marsh0 Could you please check if the warnings disappeared? |
Yup, looks good now! Thanks! |
Thanks for checking! |
Don't want to create a new thread, but I still have this warning on -W4 in VS 2017. Probably new expressions which should use the same pattern? Or maybe #pragma will really be needed. |
@eliasdaler Could you open an issue and paste the warnings? Please use the develop version. |
There is a few lines like:
That are causing warnings and make projects that treat warnings as errors unable to compile without fixing it or disabling warnings in the code.
Microsoft Visual Studio Compiler 2015
The text was updated successfully, but these errors were encountered: