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 +++++++++++++++++++++-- include/win32/config.h | 12 ++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 include/win32/config.h (limited to 'include') 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 diff --git a/include/win32/config.h b/include/win32/config.h new file mode 100644 index 0000000..00ec3bb --- /dev/null +++ b/include/win32/config.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: LGPL-3.0-or-later */ +/* + * config.h - manually created stub for MSVC + * + * Copyright (C) 2019 David Oberhollenzer + */ +#ifndef CONFIG_H +#define CONFIG_H + + + +#endif /* CONFIG_H */ -- cgit v1.2.3