From fdc341e6aa27a1108ddf3624b8457b37a0250343 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Thu, 10 Dec 2020 13:49:24 -0500 Subject: [PATCH 1/4] add an initial stab at defining a mingw macro needed to fix server 2016 --- includes/ziti/ziti_log.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/ziti/ziti_log.h b/includes/ziti/ziti_log.h index 8c06203c..eb7c1195 100644 --- a/includes/ziti/ziti_log.h +++ b/includes/ziti/ziti_log.h @@ -19,6 +19,10 @@ #define ZITI_LOG_PREFIX #endif +//on server 2016 msvcrt.dll does not process %z formatting +//that can lead to a crash if the string format is something like: %zd(%s) +#define __USE_MINGW_ANSI_STDIO + #define _to_str(x) #x #define to_str(x) _to_str(x) // for windows compilation NOGDI needs to be set: From 7b21c3e06e1eb92b06c6c5f8deda7e2d92ff6de8 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Thu, 10 Dec 2020 14:06:48 -0500 Subject: [PATCH 2/4] need a 1 on that --- includes/ziti/ziti_log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/ziti/ziti_log.h b/includes/ziti/ziti_log.h index eb7c1195..1d10a81a 100644 --- a/includes/ziti/ziti_log.h +++ b/includes/ziti/ziti_log.h @@ -21,7 +21,7 @@ //on server 2016 msvcrt.dll does not process %z formatting //that can lead to a crash if the string format is something like: %zd(%s) -#define __USE_MINGW_ANSI_STDIO +#define __USE_MINGW_ANSI_STDIO 1 #define _to_str(x) #x #define to_str(x) _to_str(x) From d3ca8d071b77e404ca6364ebb5ab628510044e11 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Thu, 10 Dec 2020 14:28:22 -0500 Subject: [PATCH 3/4] move where __USE_MINGW_ANSI_STDIO is defined to cmake in hopes that the tunneler and all downstreams will get this set --- includes/ziti/ziti_log.h | 4 ---- library/CMakeLists.txt | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/includes/ziti/ziti_log.h b/includes/ziti/ziti_log.h index 1d10a81a..8c06203c 100644 --- a/includes/ziti/ziti_log.h +++ b/includes/ziti/ziti_log.h @@ -19,10 +19,6 @@ #define ZITI_LOG_PREFIX #endif -//on server 2016 msvcrt.dll does not process %z formatting -//that can lead to a crash if the string format is something like: %zd(%s) -#define __USE_MINGW_ANSI_STDIO 1 - #define _to_str(x) #x #define to_str(x) _to_str(x) // for windows compilation NOGDI needs to be set: diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 5bf87df6..4a90f097 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -91,6 +91,16 @@ target_compile_definitions(ziti_dll PUBLIC ) if (WIN32) + if(MINGW) + #on server 2016 msvcrt.dll does not process %z formatting + #that can lead to a crash if the string format is something like: %zd(%s) + target_compile_definitions(ziti PUBLIC + __USE_MINGW_ANSI_STDIO=1 + ) + target_compile_definitions(ziti_dll PUBLIC + __USE_MINGW_ANSI_STDIO=1 + ) + endif() # on windows GDI defines ERROR which conflicts with the SDK declaration of DEBUG_LEVELS in utils.h target_compile_definitions(ziti PUBLIC NOGDI _CRT_NONSTDC_NO_DEPRECATE) target_compile_definitions(ziti_dll PUBLIC NOGDI _CRT_NONSTDC_NO_DEPRECATE) From c4e83435ac894a62d7c5c53f18133fae8cbdcc24 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Thu, 10 Dec 2020 14:52:40 -0500 Subject: [PATCH 4/4] use add_compile_definitions per review and move up to root CMakeLists.txt --- CMakeLists.txt | 5 +++++ library/CMakeLists.txt | 10 ---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 699325dc..54ea29ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,11 @@ message("") message("using ${CMAKE_GENERATOR}") if (WIN32) + if(MINGW) + #on server 2016 msvcrt.dll does not process %z formatting + #that can lead to a crash if the string format is something like: %zd(%s) + add_compile_definitions(__USE_MINGW_ANSI_STDIO=1) + endif() set(CMAKE_INSTALL_LIBDIR lib) set(CMAKE_INSTALL_INCLUDEDIR include) if(NOT CMAKE_INSTALL_PREFIX) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 4a90f097..5bf87df6 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -91,16 +91,6 @@ target_compile_definitions(ziti_dll PUBLIC ) if (WIN32) - if(MINGW) - #on server 2016 msvcrt.dll does not process %z formatting - #that can lead to a crash if the string format is something like: %zd(%s) - target_compile_definitions(ziti PUBLIC - __USE_MINGW_ANSI_STDIO=1 - ) - target_compile_definitions(ziti_dll PUBLIC - __USE_MINGW_ANSI_STDIO=1 - ) - endif() # on windows GDI defines ERROR which conflicts with the SDK declaration of DEBUG_LEVELS in utils.h target_compile_definitions(ziti PUBLIC NOGDI _CRT_NONSTDC_NO_DEPRECATE) target_compile_definitions(ziti_dll PUBLIC NOGDI _CRT_NONSTDC_NO_DEPRECATE)