Fix build on Windows with recent versions of MSVC

- vsnprintf and snprintf are available since vs2015
- define ISREG if not provided
- guard unistd.h include with HAVE_UNISTD_H
- isnan() is available after vs2010
This commit is contained in:
Mathieu Duponchelle 2018-05-31 16:07:57 -07:00 committed by Tim-Philipp Müller
parent 91b5761acd
commit a75f8df957
3 changed files with 12 additions and 2 deletions

View file

@ -201,10 +201,12 @@
#define hypot _hypot #define hypot _hypot
#define pclose _pclose #define pclose _pclose
#define popen _popen #define popen _popen
#define snprintf _snprintf
#define strdup _strdup #define strdup _strdup
#define unlink _unlink #define unlink _unlink
#define vsnprintf _vsnprintf #if _MSC_VER < 1900
#define vsnprintf _vsnprintf
#define snprintf _snprintf
#endif
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER

View file

@ -27,7 +27,9 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif
#include <cairo-ft.h> #include <cairo-ft.h>
#include <fontconfig/fontconfig.h> #include <fontconfig/fontconfig.h>
@ -73,6 +75,10 @@ check_font_extents (const cairo_test_context_t *ctx, cairo_t *cr, const char *co
return CAIRO_TEST_SUCCESS; return CAIRO_TEST_SUCCESS;
} }
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
static cairo_test_status_t static cairo_test_status_t
draw (cairo_t *cr, int width, int height) draw (cairo_t *cr, int width, int height)
{ {

View file

@ -58,7 +58,9 @@ typedef unsigned __int64 uint64_t;
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
#include <float.h> #include <float.h>
#if _MSC_VER <= 1600
#define isnan(x) _isnan(x) #define isnan(x) _isnan(x)
#endif
#endif #endif