libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
platform.h
Go to the documentation of this file.
1
9#pragma once
10
11// ============================================================================
12// Operating system detection
13// ============================================================================
14
15#if defined(__EMSCRIPTEN__)
16# define PROMEKI_PLATFORM_EMSCRIPTEN 1
17# define PROMEKI_PLATFORM "Emscripten"
18#elif defined(_WIN64)
19# define PROMEKI_PLATFORM_WINDOWS 64
20# define PROMEKI_PLATFORM "Win64"
21#elif defined(_WIN32)
22# define PROMEKI_PLATFORM_WINDOWS 32
23# define PROMEKI_PLATFORM "Win32"
24#elif defined(__APPLE__)
25# define PROMEKI_PLATFORM_APPLE 1
26# define PROMEKI_PLATFORM "MacOS"
27#elif defined(__linux__)
28# define PROMEKI_PLATFORM_LINUX 1
29# define PROMEKI_PLATFORM "Linux"
30#elif defined(__FreeBSD__)
31# define PROMEKI_PLATFORM_FREEBSD 1
32# define PROMEKI_PLATFORM "FreeBSD"
33#elif defined(__OpenBSD__)
34# define PROMEKI_PLATFORM_OPENBSD 1
35# define PROMEKI_PLATFORM "OpenBSD"
36#else
37# define PROMEKI_PLATFORM_UNKNOWN 1
38# define PROMEKI_PLATFORM "Unknown"
39#endif
40
41// Convenience macro for any POSIX-like system (not Windows)
42#if defined(PROMEKI_PLATFORM_LINUX) || defined(PROMEKI_PLATFORM_APPLE) || \
43 defined(PROMEKI_PLATFORM_FREEBSD) || defined(PROMEKI_PLATFORM_OPENBSD)
44# define PROMEKI_PLATFORM_POSIX 1
45#endif
46
47// Convenience macro for any BSD-derived system
48#if defined(PROMEKI_PLATFORM_FREEBSD) || defined(PROMEKI_PLATFORM_OPENBSD) || \
49 defined(PROMEKI_PLATFORM_APPLE)
50# define PROMEKI_PLATFORM_BSD 1
51#endif
52
53// ============================================================================
54// Compiler detection
55// ============================================================================
56
57// Note: Clang check must come before GCC check since Clang also defines __GNUC__
58#if defined(__clang__)
59# define PROMEKI_COMPILER_CLANG 1
60#elif defined(__GNUC__)
61# define PROMEKI_COMPILER_GCC 1
62#elif defined(_MSC_VER)
63# define PROMEKI_COMPILER_MSVC 1
64#endif
65
66// Convenience macro for GCC-compatible compilers (GCC or Clang)
67#if defined(PROMEKI_COMPILER_GCC) || defined(PROMEKI_COMPILER_CLANG)
68# define PROMEKI_COMPILER_GCC_COMPAT 1
69#endif
70
71// ============================================================================
72// C library detection
73// ============================================================================
74
75#if defined(__GLIBC__)
76# define PROMEKI_LIBC_GLIBC 1
77# define PROMEKI_LIBC_GLIBC_VERSION_MAJOR __GLIBC__
78# define PROMEKI_LIBC_GLIBC_VERSION_MINOR __GLIBC_MINOR__
79#endif