GithubHelp home page GithubHelp logo

fleschutz / cwts Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 2.0 243 KB

Test suite to check C++ compiler warnings with 68 test cases.

License: Creative Commons Zero v1.0 Universal

CMake 7.60% C++ 92.40%
compiler warnings c cmake collection visual-studio gcc clang suite coverage

cwts's Introduction

The C++ Warnings Test Suite (CWTS)

C++ compiler warnings are extremely helpful to prevent software bugs from the beginning on. Sadly, most warnings are either undetected or not shown by the current warning level. This repo checks the warning coverage of your C++ compiler with 68 test cases (see the .cpp files in the ๐Ÿ“‚test_cases folder).

โš™๏ธ Installation

Requires cmake and a C++ compiler installed. Then execute in a terminal window:

> git clone https://github.com/fleschutz/CWTS  # or download and unzip the ZIP file (click the green button)
> cd CWTS
> cmake .
> make -k                                      # option '-k': keep going, even on errors

Expect a lot of compiler warnings but the more warnings the better! Edit CMakeLists.txt before to force using a certain C++ compiler.

๐Ÿ† Compiler Ranking by Warnings

Each test case (or .cpp file) compiled without warnings or errors is a miss. And the winner is:

  1. clang-tidy 10.0 which misses 8 warnings only.
  2. Clang 10.0.0 which misses 11 warnings.
  3. GCC 9.3.0 which misses 14 warnings.
  4. Visual Studio 2019 which misses 17 warnings.
  5. Visual Studio 2017 which misses 19 warnings.
  6. Cppcheck 2.11 which misses 23 warnings.

See the ๐Ÿ“‚test_results folder for details and older versions. Note: all results with highest warning level enabled (see below).

โš ๏ธ How to enable the Highest Warning Level

Please note every compiler sets the default warning level to 'normal', whatever this means. And each one supports different options to be more pedantic:

Compiler Options Comment
Clang -Weverything -pedantic
clang-tidy -checks=*,-modernize* hints how to modernize the code are switched off
Cppcheck --enable=all
GCC -Wall -Wextra -pedantic -Wundef -Wall and -Wextra do not enable all warnings! To keep backwards compatibility, -Wall is basically, "All warnings as of 1990." -Wextra covers a lot of the newer warnings, but still misses a few.
Visual Studio /Wall

๐Ÿ‘ฎโ€ Zero Warnings Policy

This means your project is compiled with the highest warning level and zero compiler warnings are acceptable.

Introducing the Zero Warnings Policy by enabling the highest warning level often results in hundreds or even thousands of warnings. To get started you may want to begin with a lower warning level first. Now, fix those warnings and gradually dial up the warning level.

As soon as there are no more warnings turn warnings into errors to enforce the Zero Warnings Policy from now on. That way warnings can no longer be ignored because the build fails. The corresponding compiler options are -Werror for Clang and GCC and /WX for Visual Studio.

Dear API developers: introducing the Zero Warnings Policy heavily depends on the header files being used. Please make sure your header files do not produce any compiler warnings!

Links

๐Ÿ“ง Feedback

Send your email feedback to: markus.fleschutz [at] gmail.com

๐Ÿค License & Copyright

This open source project is licensed under the CC0 license. All trademarks are the property of their respective owners.

cwts's People

Contributors

fleschutz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

bassdscho gmh5225

cwts's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.