Skip to content

Commit

Permalink
Fixes for Visual Studio 2017.
Browse files Browse the repository at this point in the history
  • Loading branch information
ambrop72 committed Dec 30, 2018
1 parent dbf0d4a commit 2738222
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 69 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 1 addition & 5 deletions base/BLog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions base/DebugObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
typedef struct {
#ifndef NDEBUG
uint32_t c;
#else
int dummy_field; // struct must have at least one field
#endif
} DebugObject;

Expand Down
6 changes: 2 additions & 4 deletions misc/debugcounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions misc/debugerror.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
typedef struct {
#ifndef NDEBUG
BPending job;
#else
int dummy_field; // struct must have at least one field
#endif
} DebugError;

Expand Down
56 changes: 2 additions & 54 deletions misc/print_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 1 addition & 5 deletions system/BTime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2738222

Please sign in to comment.