Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
compiler.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <version>
4
5#if defined(__GNUC__) || defined(__clang__)
6#define HELIOS_EXPECT_TRUE(x) __builtin_expect(!!(x), 1)
7#define HELIOS_EXPECT_FALSE(x) __builtin_expect(!!(x), 0)
8#else
9#define HELIOS_EXPECT_TRUE(x) (x)
10#define HELIOS_EXPECT_FALSE(x) (x)
11#endif
12
13#if defined(__cpp_lib_move_only_function) && \
14 __cpp_lib_move_only_function >= 202110L
15#define HELIOS_MOVEONLY_FUNCTION_AVAILABLE
16#endif
17
18#if defined(__cpp_lib_containers_ranges) && \
19 __cpp_lib_containers_ranges >= 202202L
20#define HELIOS_CONTAINERS_RANGES_AVAILABLE
21#endif
22
23#if defined(__cpp_lib_flat_map) && __cpp_lib_flat_map >= 202207L
24#define HELIOS_STL_FLAT_MAP_AVAILABLE
25#elif defined(HELIOS_USE_STL_FLAT_MAP)
26#define HELIOS_STL_FLAT_MAP_AVAILABLE
27#endif
28
29#ifdef _MSC_VER
30#define HELIOS_FORCE_INLINE __forceinline
31#elif defined(__GNUC__) || defined(__clang__)
32#define HELIOS_FORCE_INLINE __attribute__((always_inline)) inline
33#else
34#define HELIOS_FORCE_INLINE inline
35#endif
36
37#if defined(__clang__)
38#define HELIOS_ALWAYS_INLINE [[clang::always_inline]]
39#elif defined(__GNUC__)
40#define HELIOS_ALWAYS_INLINE [[gnu::always_inline]]
41#elif defined(_MSC_VER)
42#define HELIOS_ALWAYS_INLINE [[msvc::forceinline]]
43#else
44#define HELIOS_ALWAYS_INLINE
45#endif
46
47#ifdef _MSC_VER
48#define HELIOS_NO_INLINE __declspec(noinline)
49#elif defined(__GNUC__) || defined(__clang__)
50#define HELIOS_NO_INLINE __attribute__((noinline))
51#else
52#define HELIOS_NO_INLINE
53#endif