From c988a8e36ef102a53489bdc897800f2a48e4c2df Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Fri, 27 Mar 2026 10:34:33 +0100 Subject: [PATCH] MSVC: Define _USE_MATH_DEFINES via meson.build This way M_PI and other constants are available everywhere. The constants are behind a preprocessor macro because they aren't part of standard C. --- meson.build | 1 + perf/micro/pythagoras-tree.c | 2 +- src/cairoint.h | 3 --- test/cairo-test.h | 1 - util/cairo-script/cairo-script-operators.c | 4 ---- 5 files changed, 2 insertions(+), 9 deletions(-) diff --git a/meson.build b/meson.build index 0251a88ed..98e007bca 100644 --- a/meson.build +++ b/meson.build @@ -102,6 +102,7 @@ if cc.get_id() == 'msvc' language : ['c', 'cpp']) add_project_arguments(['-D_CRT_SECURE_NO_WARNINGS', '-D_CRT_NONSTDC_NO_WARNINGS', + '-D_USE_MATH_DEFINES', ], language : ['c', 'cpp']) endif diff --git a/perf/micro/pythagoras-tree.c b/perf/micro/pythagoras-tree.c index 9d3ca1155..6581e4ed6 100644 --- a/perf/micro/pythagoras-tree.c +++ b/perf/micro/pythagoras-tree.c @@ -24,7 +24,7 @@ */ #include "cairo-perf.h" -#define _USE_MATH_DEFINES /* for M_SQRT2 on win32 */ + #include static void diff --git a/src/cairoint.h b/src/cairoint.h index b18a579be..fa8f5d395 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -55,9 +55,6 @@ #include #include -#ifdef _MSC_VER -#define _USE_MATH_DEFINES -#endif #include #include #include diff --git a/test/cairo-test.h b/test/cairo-test.h index 4a853c0d1..0a36cd7a3 100644 --- a/test/cairo-test.h +++ b/test/cairo-test.h @@ -55,7 +55,6 @@ typedef unsigned __int64 uint64_t; #endif #ifdef _MSC_VER -#define _USE_MATH_DEFINES #include #endif diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c index 27116ca6d..301080b31 100644 --- a/util/cairo-script/cairo-script-operators.c +++ b/util/cairo-script/cairo-script-operators.c @@ -46,10 +46,6 @@ #include /* mkstemp */ #include -#ifdef _MSC_VER -#define _USE_MATH_DEFINES /* for M_LN2, M_PI and M_SQRT2 on win32 */ -#endif - #include #include /* INT_MAX */ #include