From dc0657c7622f5a13afc3876eca7e2fc7cabb9a10 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 13 Apr 2023 12:23:30 +0100 Subject: [PATCH] build: Fix C4005 "macro redefinition" MSVC warnings in examples --- configure.ac | 1 - examples/CMakeLists.txt | 3 --- examples/examples_util.h | 6 ++++++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 0b555eac67..6bf5b573dd 100644 --- a/configure.ac +++ b/configure.ac @@ -122,7 +122,6 @@ AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [ # Note that "/opt" and "-opt" are equivalent for MSVC; we use "-opt" because "/opt" looks like a path. if test x"$GCC" != x"yes" && test x"$build_windows" = x"yes"; then SECP_TRY_APPEND_CFLAGS([-W2 -wd4146], $1) # Moderate warning level, disable warning C4146 "unary minus operator applied to unsigned type, result still unsigned" - SECP_TRY_APPEND_CFLAGS([-external:anglebrackets -external:W0], $1) # Suppress warnings from #include <...> files # We pass -ignore:4217 to the MSVC linker to suppress warning 4217 when # importing variables from a statically linked secp256k1. # (See the libtool manual, section "Windows DLLs" for background.) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 0884b645e0..f60cde4377 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -2,9 +2,6 @@ add_library(example INTERFACE) target_include_directories(example INTERFACE ${PROJECT_SOURCE_DIR}/include ) -target_compile_options(example INTERFACE - $<$:/wd4005> -) target_link_libraries(example INTERFACE $<$:bcrypt> ) diff --git a/examples/examples_util.h b/examples/examples_util.h index a52b1fa115..507cd5594c 100644 --- a/examples/examples_util.h +++ b/examples/examples_util.h @@ -17,7 +17,13 @@ */ #if defined(_WIN32) +/* + * The defined WIN32_NO_STATUS macro disables return code definitions in + * windows.h, which avoids "macro redefinition" MSVC warnings in ntstatus.h. + */ +#define WIN32_NO_STATUS #include +#undef WIN32_NO_STATUS #include #include #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)