From a2495bd1ac9e5e54074d65616de0efa822a6309e Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 1 Apr 2020 00:13:11 +0200 Subject: Add preliminary VisualStudio support - Mostly workarounds/clutches in compat.h - Change getline return type to int - Replace C99 style flexible array with alloca - Add all the MSVC solution/project crap Signed-off-by: David Oberhollenzer --- include/compat.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'include/compat.h') diff --git a/include/compat.h b/include/compat.h index b2bb054..5d7a052 100644 --- a/include/compat.h +++ b/include/compat.h @@ -27,6 +27,10 @@ # define SZ_ADD_OV __builtin_add_overflow # define SZ_MUL_OV __builtin_mul_overflow # endif +#elif defined(_MSC_VER) +# include +# define SZ_ADD_OV SizeTAdd +# define SZ_MUL_OV SizeTMult #else # error I do not know how to trap integer overflows with this compiler #endif @@ -40,7 +44,13 @@ # define PRI_U32 "%" PRIu32 #endif -#if SIZEOF_SIZE_T <= SIZEOF_INT +#ifdef _MSC_VER +# ifdef _WIN64 +# define PRI_SZ PRI_U64 +# else +# define PRI_SZ PRI_U32 +# endif +#elif SIZEOF_SIZE_T <= SIZEOF_INT # define PRI_SZ "%u" #elif SIZEOF_SIZE_T == SIZEOF_LONG # define PRI_SZ "%lu" @@ -73,8 +83,17 @@ #define WIN32_LEAN_AND_MEAN #include + +#include + +#ifdef _MSC_VER +# define alloca _alloca +#endif + +#define strdup _strdup #else #include +#include #endif #if defined(_WIN32) || defined(__WINDOWS__) @@ -167,7 +186,7 @@ int chdir(const char *path); #ifndef HAVE_GETLINE #include -ssize_t getline(char **line, size_t *n, FILE *fp); +int getline(char **line, size_t *n, FILE *fp); #endif #ifndef HAVE_STRNDUP -- cgit v1.2.3