From 27382229dca94f8368a1956738de77b4f14601a2 Mon Sep 17 00:00:00 2001 From: Ambroz Bizjak Date: Sun, 30 Dec 2018 13:50:02 +0100 Subject: [PATCH] Fixes for Visual Studio 2017. --- CMakeLists.txt | 3 ++- base/BLog.c | 6 +---- base/DebugObject.h | 2 ++ misc/debugcounter.h | 6 ++--- misc/debugerror.h | 2 ++ misc/print_macros.h | 56 ++------------------------------------------- system/BTime.c | 6 +---- 7 files changed, 12 insertions(+), 69 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7413cf7d2..02c6ddcb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,8 @@ if (NOT (SIZE_SIZE GREATER INT_SIZE OR SIZE_SIZE EQUAL INT_SIZE)) endif () if (MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS /wd4065 /wd4018 /wd4533 /wd4244 /wd4102) + add_definitions(-D_CRT_SECURE_NO_WARNINGS /wd4065 /wd4018 /wd4533 /wd4244 /wd4102 /wd4098 /wd4267 /wd4116) + add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS) else () add_definitions(-std=gnu99 -Wall -Wno-unused-value -Wno-parentheses -Wno-switch -Wredundant-decls -Wshadow) diff --git a/base/BLog.c b/base/BLog.c index e3f7406f5..805b34f0c 100644 --- a/base/BLog.c +++ b/base/BLog.c @@ -38,11 +38,7 @@ struct _BLog_channel blog_channel_list[] = { #include }; -struct _BLog_global blog_global = { - #ifndef NDEBUG - 0 - #endif -}; +struct _BLog_global blog_global = {0}; #endif diff --git a/base/DebugObject.h b/base/DebugObject.h index b8db287eb..dd9d4bad1 100644 --- a/base/DebugObject.h +++ b/base/DebugObject.h @@ -55,6 +55,8 @@ typedef struct { #ifndef NDEBUG uint32_t c; + #else + int dummy_field; // struct must have at least one field #endif } DebugObject; diff --git a/misc/debugcounter.h b/misc/debugcounter.h index a8a54a130..6427968b7 100644 --- a/misc/debugcounter.h +++ b/misc/debugcounter.h @@ -44,14 +44,12 @@ typedef struct { #ifndef NDEBUG int32_t c; +#else + int dummy_field; // struct must have at least one field #endif } DebugCounter; -#ifndef NDEBUG #define DEBUGCOUNTER_STATIC { 0 } -#else -#define DEBUGCOUNTER_STATIC {} -#endif /** * Initializes the object. diff --git a/misc/debugerror.h b/misc/debugerror.h index 182afd7ba..a25f0aa8c 100644 --- a/misc/debugerror.h +++ b/misc/debugerror.h @@ -52,6 +52,8 @@ typedef struct { #ifndef NDEBUG BPending job; + #else + int dummy_field; // struct must have at least one field #endif } DebugError; diff --git a/misc/print_macros.h b/misc/print_macros.h index a07fdbe41..33ea59357 100644 --- a/misc/print_macros.h +++ b/misc/print_macros.h @@ -34,65 +34,13 @@ #ifndef BADVPN_PRINT_MACROS #define BADVPN_PRINT_MACROS -#ifdef _MSC_VER +#include // size_t +#ifdef _MSC_VER #define PRIsz "Iu" - -// signed exact width (intN_t) -#define PRId8 "d" -#define PRIi8 "i" -#define PRId16 "d" -#define PRIi16 "i" -#define PRId32 "I32d" -#define PRIi32 "I32i" -#define PRId64 "I64d" -#define PRIi64 "I64i" - -// unsigned exact width (uintN_t) -#define PRIo8 "o" -#define PRIu8 "u" -#define PRIx8 "x" -#define PRIX8 "X" -#define PRIo16 "o" -#define PRIu16 "u" -#define PRIx16 "x" -#define PRIX16 "X" -#define PRIo32 "I32o" -#define PRIu32 "I32u" -#define PRIx32 "I32x" -#define PRIX32 "I32X" -#define PRIo64 "I64o" -#define PRIu64 "I64u" -#define PRIx64 "I64x" -#define PRIX64 "I64X" - -// signed maximum width (intmax_t) -#define PRIdMAX "I64d" -#define PRIiMAX "I64i" - -// unsigned maximum width (uintmax_t) -#define PRIoMAX "I64o" -#define PRIuMAX "I64u" -#define PRIxMAX "I64x" -#define PRIXMAX "I64X" - -// signed pointer (intptr_t) -#define PRIdPTR "Id" -#define PRIiPTR "Ii" - -// unsigned pointer (uintptr_t) -#define PRIoPTR "Io" -#define PRIuPTR "Iu" -#define PRIxPTR "Ix" -#define PRIXPTR "IX" - #else - -#include - #define PRIsz "zu" - #endif #endif diff --git a/system/BTime.c b/system/BTime.c index a1fa9e715..6216fcdae 100644 --- a/system/BTime.c +++ b/system/BTime.c @@ -30,9 +30,5 @@ #include #ifndef BADVPN_PLUGIN -struct _BTime_global btime_global = { - #ifndef NDEBUG - 0 - #endif -}; +struct _BTime_global btime_global = {0}; #endif