Rerun C++ SDK
Loading...
Searching...
No Matches
compiler_utils.hpp
1#pragma once
2
3// Macro for enabling and disabling the "-Wmaybe-uninitialized" warning in GCC.
4// See: https://github.com/rerun-io/rerun/issues/4027
5
6#define RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(expr) \
7 RERUN_DISABLE_MAYBE_UNINITIALIZED_PUSH \
8 expr RERUN_DISABLE_MAYBE_UNINITIALIZED_POP
9
10#if defined(__GNUC__) && !defined(__clang__)
11#define RERUN_DISABLE_MAYBE_UNINITIALIZED_PUSH \
12 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
13#else
14#define RERUN_DISABLE_MAYBE_UNINITIALIZED_PUSH
15#endif
16
17#if defined(__GNUC__) && !defined(__clang__)
18#define RERUN_DISABLE_MAYBE_UNINITIALIZED_POP _Pragma("GCC diagnostic pop")
19#else
20#define RERUN_DISABLE_MAYBE_UNINITIALIZED_POP
21#endif
22
23// Macro for marking code as unreachable.
24// Reaching the code after all is undefined behavior.
25
26#if defined(__GNUC__) || defined(__clang__)
27#define RERUN_UNREACHABLE() __builtin_unreachable()
28#elif defined(_MSC_VER)
29#define RERUN_UNREACHABLE() __assume(false)
30#else
31#define RERUN_UNREACHABLE() \
32 do { \
33 } while (false)
34#endif