Warning Levels for Visual Studio's C++ compiler
Copying an issue raised on exercism/exercism for better visibility:
In the C++ track, exercises come with a CMakeLists.txt file that configures CMake for each exercise, and I noticed that when building C++ solutions to exercises certain warnings I'd expect to see aren't appearing.
It looks like warning levels are set to be verbose for Clang and GNU compilers but there's no setting that addresses the default compiler MSVS ships with.
https://stackoverflow.com/questions/2368811/how-toset-warning-level-in-cmake/50882216#50882216
This SO answer describes how that could be addressed for visual studio, and it would be a great help to new programmers such as myself if this configuration option could be added.
Docs on MSVC compiler warnings.
At first glance it looks like we'll want /W4 and /WX and possibly /Wall.
/Wall turns on compiler warnings that are off by default. They state that:
The C runtime libraries and the C++ standard libraries are intended to emit no warnings only at warning level /W4
Do we want this? I don't have a Windows box to test on.
Warnings in stdlib wouldn't affect our projects if we only link against it, right?
An error warning level of higher than /W4 in Visual C++ tends to bury the user in warnings generated by the standard library.
https://stackoverflow.com/questions/4001736/whats-up-with-the-thousands-of-warnings-in-standard-headers-in-msvc-wall
For most users and especially newer C++ programmers, /W4 seems optimal, because most users don't need to see those warnings.
@Nolshine Thanks for the info!
We'll stick with /W4. Adding /Wall and promoting warnings to errors using /WX would mean that students would never be able to compile - not good.
I have no clue about the warning levels in MSVC to be honest, so whatever suggestion here is probably fine.
I can test this on a Windows box at some point.
@KevinWMatthews The Github Actions are now running on this repo, and they run all the tests on Windows and spit out all the output, so you should* be able to test that here. Here is the Windows run: https://github.com/exercism/cpp/runs/222211460
They should run on a PR opened against the master branch, as well as pushes to master, so you should be able to test in a PR.
- Actually I did some testing while not logged in and I don't think you'll be able to see that unless you sign up for the Github Actions beta - https://github.com/features/actions. I may try to test this, since I think I can just send you a link that would show the run.