This repository was archived by the owner on Apr 27, 2026. It is now read-only.
forked from StrikerX3/Ymir
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiler_info.hpp
More file actions
74 lines (56 loc) · 2.23 KB
/
compiler_info.hpp
File metadata and controls
74 lines (56 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
/**
@file
@brief Contains `constexpr` constants specifying information about the compiler used to build the program.
Currently supports:
- Clang on Linux, macOS and Windows
- GCC on Linux, macOS and MinGW
- MSVC on Windows
*/
#include <string>
namespace compiler {
#if defined(__clang__)
inline constexpr const char *name = "Clang";
namespace version {
inline constexpr int major = __clang_major__;
inline constexpr int minor = __clang_minor__;
inline constexpr int patch = __clang_patchlevel__;
inline const std::string string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch);
} // namespace version
#elif defined(__GNUC__)
inline constexpr const char *name = "GCC";
namespace version {
inline constexpr int major = __GNUC__;
inline constexpr int minor = __GNUC_MINOR__;
inline constexpr int patch = __GNUC_PATCHLEVEL__;
inline const std::string string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch);
} // namespace version
#elif defined(_MSC_VER)
inline constexpr const char *name = "MSVC";
namespace version {
inline constexpr int major = _MSC_VER / 100;
inline constexpr int minor = _MSC_VER % 100;
#if defined(_MSC_FULL_VER)
inline constexpr int patch = _MSC_FULL_VER % 100000;
inline const std::string string = std::to_string(major) + "." + std::to_string(minor) + "." +
std::to_string(patch) + "." + std::to_string(_MSC_BUILD);
#else
inline constexpr int patch = 0;
inline const std::string string = std::to_string(major) + "." + std::to_string(minor);
#endif
} // namespace version
#else
/// @brief The name of the compiler.
inline constexpr const char *name = "<unidentified compiler>";
namespace version {
/// @brief The major version of the compiler.
inline constexpr int major = 0;
/// @brief The minor version of the compiler.
inline constexpr int minor = 0;
/// @brief The patch version of the compiler.
inline constexpr int patch = 0;
/// @brief The version of the compiler as a string in the format `"<major>.<minor>.<patch>"`.
inline const std::string string = "0.0.0";
} // namespace version
#endif
} // namespace compiler