RAVENNAKIT
Loading...
Searching...
No Matches
platform.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-or-later
2/*
3 * Project: RAVENNAKIT (RAVENNA / AES67 / ST2110-30 SDK)
4 * Copyright (c) 2024-2025 Sound on Digital
5 *
6 * This file is part of RAVENNAKIT.
7 *
8 * RAVENNAKIT is dual-licensed:
9 * 1) Under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version (the "AGPL License"); and
12 * 2) Under a commercial license from Sound on Digital, for customers who
13 * cannot (or do not wish to) comply with the AGPL License terms.
14 *
15 * If you obtained this file under the AGPL License, you may redistribute it
16 * and/or modify it under the terms of the AGPL License. See the LICENSE
17 * file in the project root for details.
18 *
19 * For commercial licensing, support, and other inquiries, please visit:
20 *
21 * https://ravennakit.com
22 *
23 */
24
25#pragma once
26
27#include <cstdint>
28#include <string> // For size_t
29
30// Note: these constants are treated as tri-state variables, so they can be 0, 1, or undefined.
31
32// Windows
33#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
34 #define RAV_WINDOWS 1
35
36 #ifdef _WIN64
37 #define RAV_WINDOWS_64BIT 1
38 #else
39 #define RAV_WINDOWS_32BIT 1
40 #endif
41#else
42 #define RAV_WINDOWS 0
43 #define RAV_WINDOWS_64BIT 0
44 #define RAV_WINDOWS_32BIT 0
45#endif
46
47// Apple
48#if defined(__APPLE__)
49 #define RAV_APPLE 1
50 #define RAV_POSIX 1 // POSIX-certified.
51 #include <TargetConditionals.h>
52 #if TARGET_IPHONE_SIMULATOR // iOS, tvOS, or watchOS Simulator
53 #define RAV_SIMULATOR 1
54 #elif TARGET_OS_MACCATALYST // Mac's Catalyst (ports iOS API into Mac, like UIKit).
55 #define RAV_MACCATALYST 1
56 #elif TARGET_OS_IPHONE // iOS, tvOS, or watchOS device
57 #define RAV_IPHONE 1
58 #elif TARGET_OS_MAC // Apple desktop OS
59 #define RAV_MACOS 1
60 #else
61 #error "Unknown Apple platform"
62 #endif
63#else
64 #define RAV_APPLE 0
65 #define RAV_SIMULATOR 0
66 #define RAV_MACCATALYST 0
67 #define RAV_IPHONE 0
68 #define RAV_MACOS 0
69#endif
70
71// Android
72#if defined(__ANDROID__)
73 #define RAV_ANDROID 1
74 #define RAV_POSIX 1 // Mostly POSIX compliant.
75#else
76 #define RAV_ANDROID 0
77#endif
78
79// Linux
80#if defined(__linux__)
81 #define RAV_LINUX 1
82 #define RAV_POSIX 1 // Most distributions are mostly POSIX compliant.
83#else
84 #define RAV_LINUX 0
85#endif
86
87// BSD
88#if defined(__FreeBSD__) || defined(__OpenBSD__)
89 #define RAV_BSD 1
90 #define RAV_POSIX 1 // Mostly POSIX compliant.
91#else
92 #define RAV_BSD 0
93#endif
94
95// Unix
96#if defined(__unix__)
97 #define RAV_UNIX 1
98#else
99 #define RAV_UNIX 0
100#endif
101
102// Posix
103#ifndef RAV_POSIX
104 #if defined(_POSIX_VERSION)
105 #define RAV_POSIX 1
106 #else
107 #define RAV_POSIX 0
108 #endif
109#endif
110
111#ifdef RAV_WINDOWS
112 #ifndef NOMINMAX
113 #error "Please define NOMINMAX as compile constant in your build system."
114 #endif
115#endif