Skip to content

Commit 9b93667

Browse files
committed
fix: use more strict compiler flags
1 parent ba39e40 commit 9b93667

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ cc_library(
1717
name = "ncrypto",
1818
srcs = glob(["src/*.cpp"]),
1919
hdrs = glob(["include/*.h", "include/ncrypto/*.h"]),
20+
copts = [
21+
"-Werror",
22+
"-Wextra",
23+
"-Wno-unused-parameter",
24+
"-Wimplicit-fallthrough",
25+
],
2026
includes = ["include"],
2127
local_defines = {
2228
"NCRYPTO_BSSL_LIBDECREPIT_MISSING": select(

cmake/ncrypto-flags.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ set(CMAKE_CXX_STANDARD 20)
99
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1010
set(CMAKE_CXX_EXTENSIONS OFF)
1111

12+
13+
1214
find_program(CCACHE_FOUND ccache)
1315
if(CCACHE_FOUND)
1416
message(STATUS "Ccache found using it as compiler launcher.")

include/ncrypto/aead.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Aead final {
1919

2020
public:
2121
Aead() = default;
22-
Aead(const AeadInfo* info, const EVP_AEAD* aead) : info_(info), aead_(aead) {}
22+
Aead(const AeadInfo* info, const EVP_AEAD* aead) : aead_(aead), info_(info) {}
2323
Aead(const Aead&) = default;
2424
Aead& operator=(const Aead&) = default;
2525
NCRYPTO_DISALLOW_MOVE(Aead)

src/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
add_library(ncrypto ncrypto.cpp engine.cpp aead.cpp)
2+
3+
# Enable strict warning flags for ncrypto sources only
4+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
5+
target_compile_options(ncrypto PRIVATE -Werror -Wextra -Wno-unused-parameter -Wimplicit-fallthrough)
6+
endif()
7+
if(MSVC)
8+
target_compile_options(ncrypto PRIVATE /WX /W4)
9+
endif()
10+
211
if (NCRYPTO_SHARED_LIBS)
312
target_link_libraries(ncrypto PUBLIC OpenSSL::SSL OpenSSL::Crypto)
413
else()

0 commit comments

Comments
 (0)