repr 0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
platform.h
Go to the documentation of this file.
1#pragma once
2#include <librepr/feature.h>
3
4namespace librepr {
5
6enum class Platform : unsigned { Unknown, Linux, UNIX, Windows, macOS };
7enum class Compiler : unsigned { Unknown, Clang, GCC, MSVC };
8
9#if defined(_WIN32)
10#define LIBREPR_PLATFORM_WINDOWS ON
11constexpr inline auto platform = Platform::Windows;
12
13#elif defined(__linux__)
14#define LIBREPR_PLATFORM_LINUX ON
15constexpr inline auto platform = Platform::Linux;
16
17#elif defined(__APPLE__)
18#define LIBREPR_PLATFORM_MACOS ON
19constexpr inline auto platform = Platform::macOS;
20
21#elif defined(unix) || defined(__unix__) || defined(__unix)
22#define LIBREPR_PLATFORM_UNIX ON
23constexpr inline auto platform = Platform::UNIX;
24
25#else
26#warning "Unsupported platform"
27constexpr inline auto compiler = Platform::Unknown;
28#endif
29
30#if !defined(LIBREPR_PLATFORM_WINDOWS)
31# define LIBREPR_PLATFORM_WINDOWS OFF
32#endif
33
34#if !defined(LIBREPR_PLATFORM_LINUX)
35# define LIBREPR_PLATFORM_LINUX OFF
36#endif
37
38#if !defined(LIBREPR_PLATFORM_MACOS)
39# define LIBREPR_PLATFORM_MACOS OFF
40#endif
41
42#if !defined(LIBREPR_PLATFORM_UNIX)
43# define LIBREPR_PLATFORM_UNIX OFF
44#endif
45
46
47#if defined(__clang__)
48#define LIBREPR_COMPILER_CLANG ON
49constexpr inline auto compiler = Compiler::Clang;
50
51#elif defined(__GNUC__) || defined(__GNUG__)
52#define LIBREPR_COMPILER_GCC ON
53constexpr inline auto compiler = Compiler::GCC;
54
55#elif defined(_MSC_VER)
56#define LIBREPR_COMPILER_MSVC ON
57constexpr inline auto compiler = Compiler::MSVC;
58
59#else
60#warning "Unsupported compiler"
61constexpr inline auto compiler = Compiler::Unknown;
62#endif
63
64#if !defined(LIBREPR_COMPILER_CLANG)
65# define LIBREPR_COMPILER_CLANG OFF
66#endif
67
68#if !defined(LIBREPR_COMPILER_GCC)
69# define LIBREPR_COMPILER_GCC OFF
70#endif
71
72#if !defined(LIBREPR_COMPILER_MSVC)
73# define LIBREPR_COMPILER_MSVC OFF
74#endif
75
76
77#if USING(LIBREPR_COMPILER_MSVC)
78#define LIBREPR_FUNCTION_NAME __FUNCSIG__
79#else
80#define LIBREPR_FUNCTION_NAME __PRETTY_FUNCTION__
81#endif
82
83} // namespace librepr
Definition ctvi/ctvi.h:9
std::string code_for()
Definition repr:39
Compiler
Definition platform.h:7
constexpr auto compiler
Definition platform.h:27
Platform
Definition platform.h:6