meson: Define G_OS_DARWIN when compiling under OSX or iOS

It has enough differences to expose it as an unix-subtype.
This commit is contained in:
Marco Trevisan (Treviño) 2022-10-18 21:59:59 +02:00
parent 4b6cc2d87b
commit e85635daa0
5 changed files with 31 additions and 0 deletions

View File

@ -196,6 +196,11 @@ GCond *cond
# Definitions for different operating systems # Definitions for different operating systems
<MACRO>
<NAME>G_OS_DARWIN</NAME>
#define G_OS_DARWIN
</MACRO>
<MACRO> <MACRO>
<NAME>G_OS_UNIX</NAME> <NAME>G_OS_UNIX</NAME>
#define G_OS_UNIX #define G_OS_UNIX

View File

@ -140,6 +140,7 @@ GLIB_VERSION_PREV_STABLE
<TITLE>Standard Macros</TITLE> <TITLE>Standard Macros</TITLE>
<FILE>macros</FILE> <FILE>macros</FILE>
<SUBSECTION> <SUBSECTION>
G_OS_DARWIN
G_OS_WIN32 G_OS_WIN32
G_OS_UNIX G_OS_UNIX

View File

@ -1647,6 +1647,17 @@
* These macros provide a few commonly-used features. * These macros provide a few commonly-used features.
*/ */
/**
* G_OS_DARWIN:
*
* This macro is defined only on Apple operating systems (macOS or iOS).
* So you can bracket Apple-specific code in `\#ifdef G_OS_DARWIN`.
*
* Note that %G_OS_UNIX is also set.
*
* Since: 2.76
*/
/** /**
* G_OS_WIN32: * G_OS_WIN32:
* *

View File

@ -20,8 +20,19 @@
* Author: Philip Withnall <withnall@endlessm.com> * Author: Philip Withnall <withnall@endlessm.com>
*/ */
#include "config.h"
#include <glib.h> #include <glib.h>
#if defined (__APPLE__) || defined (HAVE_COCOA) || defined (HAVE_CARBON)
# ifndef G_OS_UNIX
G_STATIC_ASSERT (FALSE);
# endif
# ifndef G_OS_DARWIN
G_STATIC_ASSERT (FALSE);
# endif
#endif
/* Test that G_STATIC_ASSERT_EXPR can be used as an expression */ /* Test that G_STATIC_ASSERT_EXPR can be used as an expression */
static void static void
test_assert_static (void) test_assert_static (void)

View File

@ -235,6 +235,9 @@ if host_system == 'windows'
elif host_system == 'cygwin' elif host_system == 'cygwin'
glib_os = '''#define G_OS_UNIX glib_os = '''#define G_OS_UNIX
#define G_WITH_CYGWIN''' #define G_WITH_CYGWIN'''
elif host_system in ['darwin', 'ios']
glib_os = '''#define G_OS_UNIX
#define G_OS_DARWIN'''
else else
glib_os = '#define G_OS_UNIX' glib_os = '#define G_OS_UNIX'
endif endif