Skip to content

Commit

Permalink
ci: add /WX (warnings as errors) compile flag when compiling with MSV…
Browse files Browse the repository at this point in the history
…C. (#923)

* Add /WX (warnings as errors) compile flag when compiling with MSVC.

* Call darts::score() with floats instead of doubles to get rid of C4305.

* Suppress C4244 and C4267 because lots of code triggers them and GCC and CLang are fine with those conversions.

* Add missing endif to CMakeLists.txt for sieve.
  • Loading branch information
heijp06 authored Nov 3, 2024
1 parent 3d106a5 commit 19bef29
Show file tree
Hide file tree
Showing 96 changed files with 391 additions and 106 deletions.
5 changes: 4 additions & 1 deletion exercises/concept/doctor-data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/election-day/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/ellens-alien-game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/freelancer-rates/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/interest-is-interesting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/lasagna-master/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/lasagna/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/last-will/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/log-levels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/making-the-grade/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/pacman-rules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/troll-the-trolls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/concept/vehicle-purchase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/acronym/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/all-your-base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/allergies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/anagram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/armstrong-numbers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/atbash-cipher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/bank-account/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/beer-song/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/binary-search-tree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/binary-search/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/binary/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/bob/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/circular-buffer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/clock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/collatz-conjecture/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ if(${EXERCISM_RUN_ALL_TESTS})
endif()

# Tell MSVC not to warn us about unchecked iterators in debug builds
# Treat warnings as errors
# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS "/WX /w44244 /w44267")
endif()

# Run the tests on every build
Expand Down
Loading

0 comments on commit 19bef29

Please sign in to comment.