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

Warning Levels for Visual Studio's C++ compiler #302

Open
KevinWMatthews opened this issue Aug 11, 2019 · 5 comments
Open

Warning Levels for Visual Studio's C++ compiler #302

KevinWMatthews opened this issue Aug 11, 2019 · 5 comments

Comments

@KevinWMatthews
Copy link
Contributor

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.

@KevinWMatthews
Copy link
Contributor Author

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?

@KevinWMatthews KevinWMatthews changed the title Warninig Levels for Visual Studio's C++ compiler Warning Levels for Visual Studio's C++ compiler Aug 11, 2019
@Nolshine
Copy link

Nolshine commented Aug 12, 2019

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.

@KevinWMatthews
Copy link
Contributor Author

@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.

@arcuru
Copy link
Contributor

arcuru commented Aug 17, 2019

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.

@arcuru
Copy link
Contributor

arcuru commented Sep 14, 2019

@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.

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

Successfully merging a pull request may close this issue.

3 participants