-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
All: fix warnings when compiling with -Wswitch-enum #2927
Conversation
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am surprised that fixing this warning does not come at the expense of another warning coming up - at least in the past, we always have had to suppress one of the switch warnings.
Can you please remove the -Wno-switch-enum
from https://github.com/nlohmann/json/blob/develop/cmake/ci.cmake#L102 and replace -Wno-switch-enum
by -Wswitch-enum
in https://github.com/nlohmann/json/blob/develop/cmake/ci.cmake#L329? Then the CI is actually checking whether the warning is really gone.
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Done.
|
@nlohmann The warning that you're thinking of is |
Works fine on Debian 10.10 with gcc as well. |
I checked the other issues that are mentioned (did not see them before). If the currently feeling is the same as before, then no problem because I'll just keep this as a private patch in our repo. Personally I do prefer the gcc way because it makes the code explicit and therefore easier to read and reason about. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the warnings raised by Clang and GCC all complain about some switches which have not yet been touched by the PR. I think they can be fixed similarly.
I'm a bit surprised that there are now errors on files I didn't touch. |
Did you compile the unit test suite? |
I followed the instructions of the PR, I did as described here: https://github.com/nlohmann/json/blob/develop/README.md#execute-unit-tests |
I see - but I guess the CI uses a different set of warnings. |
Then if you let me know how I should compile it, I'll see if I can fix those warnings as well. |
Try this: mkdir build
cd build
cmake .. -DJSON_CI=ON Then make ci_test_gcc for GCC with all flags and make ci_test_clang for Clang with all flags. |
(Or just check out the results of https://github.com/nlohmann/json/pull/2927/checks?check_run_id=3314908857 and https://github.com/nlohmann/json/pull/2927/checks?check_run_id=3314909773) |
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Adjusted. |
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add // LCOV_EXCL_LINE
to the added branches, as the coverage has decreased.
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Thanks for the patience! I will merge this as soon as the CI is done. |
success! |
Signed-off-by: Ferry Huberts ferry.huberts@pelagic.nl
[Describe your pull request here. Please read the text below the line, and make sure you follow the checklist.]
Pull request checklist
Read the Contribution Guidelines for detailed information.
include/nlohmann
directory, runmake amalgamate
to create the single-header filesingle_include/nlohmann/json.hpp
. The whole process is described here.Please don't
#ifdef
s or other means.