Jelajahi Sumber

Fixes for Visual Studio 2017.

Ambroz Bizjak 7 tahun lalu
induk
melakukan
27382229dc
7 mengubah file dengan 12 tambahan dan 69 penghapusan
  1. 2 1
      CMakeLists.txt
  2. 1 5
      base/BLog.c
  3. 2 0
      base/DebugObject.h
  4. 2 4
      misc/debugcounter.h
  5. 2 0
      misc/debugerror.h
  6. 2 54
      misc/print_macros.h
  7. 1 5
      system/BTime.c

+ 2 - 1
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)
 

+ 1 - 5
base/BLog.c

@@ -38,11 +38,7 @@ struct _BLog_channel blog_channel_list[] = {
 #include <generated/blog_channels_list.h>
 };
 
-struct _BLog_global blog_global = {
-    #ifndef NDEBUG
-    0
-    #endif
-};
+struct _BLog_global blog_global = {0};
 
 #endif
 

+ 2 - 0
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;
 

+ 2 - 4
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.

+ 2 - 0
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;
 

+ 2 - 54
misc/print_macros.h

@@ -34,65 +34,13 @@
 #ifndef BADVPN_PRINT_MACROS
 #define BADVPN_PRINT_MACROS
 
-#ifdef _MSC_VER
+#include <inttypes.h>
 
 // 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 <inttypes.h>
-
 #define PRIsz "zu"
-
 #endif
 
 #endif

+ 1 - 5
system/BTime.c

@@ -30,9 +30,5 @@
 #include <system/BTime.h>
 
 #ifndef BADVPN_PLUGIN
-struct _BTime_global btime_global = {
-    #ifndef NDEBUG
-    0
-    #endif
-};
+struct _BTime_global btime_global = {0};
 #endif