Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
feature_flags_core.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
16#pragma once
17
18//==============================================================================
19// Preprocessor Helpers
20//==============================================================================
21
28#ifdef __has_include
29 #define KCENON_HAS_INCLUDE(x) __has_include(x)
30#else
31 #define KCENON_HAS_INCLUDE(x) 0
32#endif
33
37#ifdef __has_cpp_attribute
38 #define KCENON_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
39#else
40 #define KCENON_HAS_CPP_ATTRIBUTE(x) 0
41#endif
42
46#ifdef __has_feature
47 #define KCENON_HAS_FEATURE(x) __has_feature(x)
48#else
49 #define KCENON_HAS_FEATURE(x) 0
50#endif
51
55#ifdef __has_builtin
56 #define KCENON_HAS_BUILTIN(x) __has_builtin(x)
57#else
58 #define KCENON_HAS_BUILTIN(x) 0
59#endif
60
61//==============================================================================
62// Compiler Detection
63//==============================================================================
64
65// Detect compilers
66#if defined(_MSC_VER)
67 #define KCENON_COMPILER_MSVC 1
68 #define KCENON_COMPILER_VERSION _MSC_VER
69#else
70 #define KCENON_COMPILER_MSVC 0
71#endif
72
73#if defined(__clang__)
74 #define KCENON_COMPILER_CLANG 1
75 #define KCENON_CLANG_VERSION \
76 (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
77#else
78 #define KCENON_COMPILER_CLANG 0
79 #define KCENON_CLANG_VERSION 0
80#endif
81
82#if defined(__GNUC__) && !defined(__clang__)
83 #define KCENON_COMPILER_GCC 1
84 #define KCENON_GCC_VERSION \
85 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
86#else
87 #define KCENON_COMPILER_GCC 0
88 #define KCENON_GCC_VERSION 0
89#endif
90
91//==============================================================================
92// C++ Standard Detection
93//==============================================================================
94
95#if defined(_MSVC_LANG)
96 #define KCENON_CPLUSPLUS _MSVC_LANG
97#else
98 #define KCENON_CPLUSPLUS __cplusplus
99#endif
100
101#define KCENON_HAS_CPP17 (KCENON_CPLUSPLUS >= 201703L)
102#define KCENON_HAS_CPP20 (KCENON_CPLUSPLUS >= 202002L)
103#define KCENON_HAS_CPP23 (KCENON_CPLUSPLUS >= 202302L)
104
105//==============================================================================
106// Platform Detection
107//==============================================================================
108
109#if defined(_WIN32) || defined(_WIN64)
110 #define KCENON_PLATFORM_WINDOWS 1
111#else
112 #define KCENON_PLATFORM_WINDOWS 0
113#endif
114
115#if defined(__linux__)
116 #define KCENON_PLATFORM_LINUX 1
117#else
118 #define KCENON_PLATFORM_LINUX 0
119#endif
120
121#if defined(__APPLE__) && defined(__MACH__)
122 #define KCENON_PLATFORM_MACOS 1
123#else
124 #define KCENON_PLATFORM_MACOS 0
125#endif
126
127#define KCENON_PLATFORM_UNIX \
128 (KCENON_PLATFORM_LINUX || KCENON_PLATFORM_MACOS)
129
130//==============================================================================
131// Legacy Alias Configuration
132//==============================================================================
133
144#ifndef KCENON_ENABLE_LEGACY_ALIASES
145 #define KCENON_ENABLE_LEGACY_ALIASES 1
146#endif
147
155#if KCENON_ENABLE_LEGACY_ALIASES
156 #define KCENON_DEFINE_LEGACY_ALIAS(legacy_name, new_name) \
157 do { } while(0)
158 // Legacy alias definitions are handled in feature_flags.h
159 // after all KCENON_* macros are established
160#endif