From 1ec2a448e9966d99c5f969c926d6e09da4058a1f Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Fri, 27 Mar 2026 10:27:22 +0100 Subject: [PATCH] MSVC: Define _CRT_NONSTDC_NO_WARNINGS We follow the convention that POSIX functions which aren't part of C don't have an underscore. --- meson.build | 4 +++- src/cairo-compiler-private.h | 9 --------- test/cairo-test.c | 1 - test/cairo-test.h | 5 ----- util/cairo-script/cairo-script-operators.c | 1 - 5 files changed, 3 insertions(+), 17 deletions(-) diff --git a/meson.build b/meson.build index 2fb22007b..0251a88ed 100644 --- a/meson.build +++ b/meson.build @@ -100,7 +100,9 @@ if cc.get_id() == 'msvc' # Turn " undefined, assuming extern returning int" to an error '/we4013', language : ['c', 'cpp']) - add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language : ['c', 'cpp']) + add_project_arguments(['-D_CRT_SECURE_NO_WARNINGS', + '-D_CRT_NONSTDC_NO_WARNINGS', + ], language : ['c', 'cpp']) endif add_project_arguments('-D_GNU_SOURCE', language: ['c', 'cpp']) diff --git a/src/cairo-compiler-private.h b/src/cairo-compiler-private.h index 1aaced394..90fd28019 100644 --- a/src/cairo-compiler-private.h +++ b/src/cairo-compiler-private.h @@ -154,20 +154,11 @@ #endif #if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER) -#define access _access #ifndef R_OK #define R_OK 4 #endif -#define fdopen _fdopen -#define hypot _hypot #define pclose _pclose #define popen _popen -#define strdup _strdup -#define unlink _unlink -#if defined (_MSC_VER) && _MSC_VER < 1900 - #define vsnprintf _vsnprintf - #define snprintf _snprintf -#endif #endif #if defined(_MSC_VER) && defined(_M_IX86) diff --git a/test/cairo-test.c b/test/cairo-test.c index 347ade7a8..f6e25647c 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -70,7 +70,6 @@ #include #define F_OK 0 #define HAVE_MKDIR 1 -#define mkdir _mkdir #endif #ifndef FALSE diff --git a/test/cairo-test.h b/test/cairo-test.h index b70654654..4a853c0d1 100644 --- a/test/cairo-test.h +++ b/test/cairo-test.h @@ -56,12 +56,7 @@ typedef unsigned __int64 uint64_t; #ifdef _MSC_VER #define _USE_MATH_DEFINES - #include -#if _MSC_VER <= 1600 -#define isnan(x) _isnan(x) -#endif - #endif #if HAVE_FENV_H diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c index a5eca6ffc..27116ca6d 100644 --- a/util/cairo-script/cairo-script-operators.c +++ b/util/cairo-script/cairo-script-operators.c @@ -48,7 +48,6 @@ #ifdef _MSC_VER #define _USE_MATH_DEFINES /* for M_LN2, M_PI and M_SQRT2 on win32 */ -#define snprintf _snprintf #endif #include