Merge branch 'wip/smcv/os-detect' into 'main'

docs: Mention platform-specific predefined macros

See merge request GNOME/glib!2997
This commit is contained in:
Philip Withnall 2022-11-01 11:00:03 +00:00
commit 110cddb90c

View File

@ -2020,6 +2020,22 @@
*
* This macro is defined only on UNIX. So you can bracket
* UNIX-specific code in "\#ifdef G_OS_UNIX".
*
* To detect whether to compile features that require a specific kernel
* or operating system, check for the appropriate OS-specific predefined
* macros instead, for example:
*
* - Linux kernel (any libc, including glibc, musl or Android): `\#ifdef __linux__`
* - Linux kernel and GNU user-space: `\#if defined(__linux__) && defined(__GLIBC__)`
* - FreeBSD kernel (any libc, including glibc): `\#ifdef __FreeBSD_kernel__`
* - FreeBSD kernel and user-space: `\#ifdef __FreeBSD__`
*
* See <https://sourceforge.net/p/predef/wiki/OperatingSystems/> for more.
*
* GLib defines OS-detection macros for some categories of systems
* that can be less straightforward to detect, such as %G_OS_DARWIN, but
* intentionally does not provide its own equivalents of macros like
* `__linux__`.
*/
/**