Skip to content

Commit 5cb36a1

Browse files
committed
Enabled as many warnings as possible and marked them as error.
Fixes #12.
1 parent c41888d commit 5cb36a1

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

cmake/CMakeCompiler.cmake

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ cmake_minimum_required (VERSION 3.2)
33
macro(setup_default_compiler_flags _project_name)
44
if(MSVC)
55
# Replace some default compiler switches and add new ones
6-
STRING(REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable RTTI
7-
STRING(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Bump warnings to W4
6+
STRING(REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable RTTI
7+
STRING(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Bump warnings to W4
88
target_compile_options(${_project_name} PRIVATE /Zi) # Add debug info
99
target_compile_options(${_project_name} PRIVATE /Oi) # Generate intrinsic functions
10-
11-
# Disable some warnings
12-
target_compile_options(${_project_name} PRIVATE /wd4100) # unreferenced formal parameter
13-
target_compile_options(${_project_name} PRIVATE /wd4324) # structure was padded due to alignment specified
14-
target_compile_options(${_project_name} PRIVATE /wd4127) # conditional expression is constant
10+
target_compile_options(${_project_name} PRIVATE /WX) # Treat warnings as errors
1511

1612
if(MSVC_VERSION GREATER 1900)
1713
# VS2017 and above
@@ -29,5 +25,8 @@ macro(setup_default_compiler_flags _project_name)
2925
target_compile_options(${_project_name} PRIVATE "-m64")
3026
target_link_libraries(${_project_name} PRIVATE "-m64")
3127
endif()
28+
29+
target_compile_options(${_project_name} PRIVATE -Wall) # Enable all warnings
30+
target_compile_options(${_project_name} PRIVATE -Werror) # Treat warnings as errors
3231
endif()
3332
endmacro()

includes/sjson/error.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
{
7272
inline void on_assert_abort(const char* expression, int line, const char* file, const char* format, ...)
7373
{
74+
(void)expression;
75+
(void)line;
76+
(void)file;
77+
7478
va_list args;
7579
va_start(args, format);
7680

@@ -100,6 +104,10 @@
100104
{
101105
inline void on_assert_throw(const char* expression, int line, const char* file, const char* format, ...)
102106
{
107+
(void)expression;
108+
(void)line;
109+
(void)file;
110+
103111
constexpr int buffer_size = 64 * 1024;
104112
char buffer[buffer_size];
105113

includes/sjson/writer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ namespace sjson
6868

6969
virtual void write(const void* buffer, size_t buffer_size) override
7070
{
71+
(void)buffer_size;
7172
fprintf(m_file, "%s", reinterpret_cast<const char*>(buffer));
7273
}
7374

tests/sources/test_writer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ TEST_CASE("Writer Object Array Writing", "[writer]")
331331
{
332332
StringStreamWriter str_writer;
333333
Writer writer(str_writer);
334-
writer.insert("key", [](ArrayWriter& array_writer)
334+
writer.insert("key", [](ArrayWriter& /*array_writer*/)
335335
{
336336
});
337337
REQUIRE(str_writer.str() == "key = [ ]\r\n");
@@ -365,7 +365,7 @@ TEST_CASE("Writer Object Object Writing", "[writer]")
365365
{
366366
StringStreamWriter str_writer;
367367
Writer writer(str_writer);
368-
writer.insert("key", [](ObjectWriter& object_writer)
368+
writer.insert("key", [](ObjectWriter& /*object_writer*/)
369369
{
370370
});
371371
REQUIRE(str_writer.str() == "key = {\r\n}\r\n");
@@ -598,7 +598,7 @@ TEST_CASE("Writer Array Array Writing", "[writer]")
598598
Writer writer(str_writer);
599599
writer.insert("key", [](ArrayWriter& array_writer)
600600
{
601-
array_writer.push([](ArrayWriter& array_writer)
601+
array_writer.push([](ArrayWriter& /*array_writer*/)
602602
{
603603
});
604604
});
@@ -627,7 +627,7 @@ TEST_CASE("Writer Array Object Writing", "[writer]")
627627
Writer writer(str_writer);
628628
writer.insert("key", [](ArrayWriter& array_writer)
629629
{
630-
array_writer.push([](ObjectWriter& object_writer)
630+
array_writer.push([](ObjectWriter& /*object_writer*/)
631631
{
632632
});
633633
});

0 commit comments

Comments
 (0)