-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Exercises are not compiled with "warnings as errors" with MSVC (Microsoft Visual C++). #922
Comments
Hello. Thanks for opening an issue on Exercism 🙂 At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories. This issue will be automatically closed. Please use this link to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you! If you're interested in learning more about this auto-responder, please read this blog post. |
@vaeng I opened this issue, but it was auto-closed. I am not really sure how to navigate this. I do not want to spam the forum, so this seemed more appropriate. Maybe I should also stop spamming here 🙂, let me know what you think. I can pick up the issue if you think it is worthwhile. The change I propose to make is one that I consistently make to |
No need to post to the forums, if you ping me here. The forums are pretty quiet for CPP, so I don't mind the post there either. Do what feels best for you In general I really appreciate the work you do for Windows, as it is often overlooked by our regulars, but heavily used by beginners. Please keep in mind that I'm currently pretty busy and the other maintainers are somewhat inactive at the moment. |
When compiling with CLang or GCC warnings are treated as errors. The relevant part of CMakeLists.txt is this:
For MSVC no such option is set. As a consequence code that contains mistakes that the user should be guarded against (e.g. not returning a value in all code paths) compiles without errors. Also when uploading the code to the website the stricter rules on the server will make code that compiled locally fail there.
Setting warnings as errors for MSVC is not that hard. There is an MSVC specific part in CMakeLists.txt:
This can be changed to:
Compiling with
/WX
will make MSVC treat warnings as errors.If this change is deemed useful, I can pick it up.
As an aside, the GCC/CLang
COMPILE_FLAGS
:-Wall -Wextra -Wpedantic
also raise the warning level of the compiler.This is also possible for MSVC. The default warning level for MSVC is
/W3
, this can be set to/W4
or/Wall
. I experimented with those levels and I do NOT propose setting those higher levels. E.g. with/WX /W4
the following code:Will fail to compile because the compiler warns (as error) about a possible loss of precision when setting
capital_a
(achar
) to the return value oftoupper()
(anint
).The text was updated successfully, but these errors were encountered: