StormByte C++ Library 1.2.0
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
platform.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte.
5 *
6 * StormByte is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version 3
8 * or later, as published by the Free Software Foundation.
9 *
10 * StormByte is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with StormByte. If not, see
17 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
18 */
19
20#pragma once
21
22// ---------------------------------------------------------------------------
23// Operating system
24// ---------------------------------------------------------------------------
25#if defined(_WIN32) || defined(__CYGWIN__)
26 #define WINDOWS
27#elif defined(__APPLE__) && defined(__MACH__)
28 #define MACOS
29 #define UNIX
30#elif defined(__linux__)
31 #define LINUX
32 #define UNIX
33#elif defined(__unix__) || defined(__unix)
34 #define UNIX
35#else
36 #error "Unsupported operating system"
37#endif
38
39// ---------------------------------------------------------------------------
40// Architecture (pointer / ILP model)
41// ---------------------------------------------------------------------------
42#if defined(_WIN64) || defined(__x86_64__) || defined(__amd64__) \
43 || defined(__aarch64__) || defined(_M_X64) || defined(_M_ARM64) \
44 || (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8)
45 #define BIT64
46#elif defined(_WIN32) || defined(__i386__) || defined(__i386) \
47 || defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) \
48 || (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4)
49 #define BIT32
50#else
51 #error "Unsupported architecture (expected 32-bit or 64-bit)"
52#endif
53
54// ---------------------------------------------------------------------------
55// Compiler
56// ---------------------------------------------------------------------------
57#if defined(__clang__)
58 #define CLANG
59#elif defined(__GNUC__) || defined(__GNUG__)
60 #define GCC
61#elif defined(_MSC_VER)
62 #define MSVC
63#endif