Merge branch 'msvc-enhancements' into 'master'

Draft: Small enhancements for MSVC and CLangCL

See merge request cairo/cairo!655
This commit is contained in:
Luca Bacci 2026-05-08 13:15:39 +00:00
commit 46d318aa70
9 changed files with 20 additions and 27 deletions

View file

@ -90,15 +90,20 @@ if cc.get_id() != 'msvc'
conf.set('WARN_UNUSED_RESULT', warn_unused_result)
endif
if cc.get_id() == 'msvc'
if cc.get_argument_syntax() == 'msvc'
# Basic usage in the cairo type system that causes spammy and useless warnings
add_project_arguments('/wd4244', '/wd4146',
# Don't warn about double -> float truncation
'/wd4305',
# Don't warn about _cairo_status -> _cairo_int_status conversion
'/wd5286',
# Turn "<function> 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',
'-D_USE_MATH_DEFINES',
], language : ['c', 'cpp'])
endif
add_project_arguments('-D_GNU_SOURCE', language: ['c', 'cpp'])

View file

@ -24,7 +24,7 @@
*/
#include "cairo-perf.h"
#define _USE_MATH_DEFINES /* for M_SQRT2 on win32 */
#include <math.h>
static void

View file

@ -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)

View file

@ -55,9 +55,6 @@
#include <stdarg.h>
#include <stddef.h>
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#include <limits.h>
#include <stdio.h>

View file

@ -87,6 +87,10 @@
#include <fcntl.h>
#endif
#ifdef _WIN32
#include <io.h>
#endif
#if HAVE_UNISTD_H && HAVE_SIGNAL_H && HAVE_SYS_STAT_H && HAVE_SYS_SOCKET_H && (HAVE_POLL_H || HAVE_SYS_POLL_H) && HAVE_SYS_UN_H
#include <signal.h>
#include <sys/stat.h>

View file

@ -67,9 +67,9 @@
#ifdef _MSC_VER
#include <crtdbg.h>
#include <direct.h>
#include <io.h>
#define F_OK 0
#define HAVE_MKDIR 1
#define mkdir _mkdir
#endif
#ifndef FALSE

View file

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

View file

@ -41,6 +41,13 @@
#include <sys/mman.h>
#endif
#ifdef _WIN32
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#endif
#include <cairo.h>
#if CAIRO_HAS_PDF_SURFACE

View file

@ -46,11 +46,6 @@
#include <stdlib.h> /* mkstemp */
#include <string.h>
#ifdef _MSC_VER
#define _USE_MATH_DEFINES /* for M_LN2, M_PI and M_SQRT2 on win32 */
#define snprintf _snprintf
#endif
#include <math.h>
#include <limits.h> /* INT_MAX */
#include <assert.h>