Common System
0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
feature_flags_example.cpp
Go to the documentation of this file.
1
// BSD 3-Clause License
2
// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3
// See the LICENSE file in the project root for full license information.
4
14
15
#include <
kcenon/common/config/feature_flags.h
>
16
17
#include <iostream>
18
#include <string>
19
20
#if KCENON_HAS_SOURCE_LOCATION
21
#include <source_location>
22
#endif
23
24
// Helper to convert bool to string
25
constexpr
const
char
*
yes_no
(
bool
v) {
return
v ?
"yes"
:
"no"
; }
26
27
int
main
()
28
{
29
std::cout <<
"=== Feature Flags Example ===\n\n"
;
30
31
// 1. C++ Standard Library Features
32
std::cout <<
"1. C++ Standard Library Features:\n"
;
33
34
#if KCENON_HAS_SOURCE_LOCATION
35
std::cout <<
" std::source_location: supported\n"
;
36
#else
37
std::cout <<
" std::source_location: not supported (using polyfill)\n"
;
38
#endif
39
40
#if KCENON_HAS_JTHREAD
41
std::cout <<
" std::jthread: supported\n"
;
42
#else
43
std::cout <<
" std::jthread: not supported\n"
;
44
#endif
45
46
#ifdef __cpp_concepts
47
std::cout <<
" C++20 concepts: supported (__cpp_concepts="
<< __cpp_concepts <<
")\n"
;
48
#else
49
std::cout <<
" C++20 concepts: not supported\n"
;
50
#endif
51
52
#ifdef __cpp_lib_format
53
std::cout <<
" std::format: supported\n"
;
54
#else
55
std::cout <<
" std::format: not supported\n"
;
56
#endif
57
58
// 2. Ecosystem System Dependencies
59
std::cout <<
"\n2. Ecosystem System Dependencies:\n"
;
60
61
#if KCENON_WITH_THREAD_SYSTEM
62
std::cout <<
" thread_system: linked\n"
;
63
#else
64
std::cout <<
" thread_system: not linked\n"
;
65
#endif
66
67
#if KCENON_WITH_LOGGER_SYSTEM
68
std::cout <<
" logger_system: linked\n"
;
69
#else
70
std::cout <<
" logger_system: not linked\n"
;
71
#endif
72
73
#if KCENON_WITH_MONITORING_SYSTEM
74
std::cout <<
" monitoring_system: linked\n"
;
75
#else
76
std::cout <<
" monitoring_system: not linked\n"
;
77
#endif
78
79
#if KCENON_WITH_CONTAINER_SYSTEM
80
std::cout <<
" container_system: linked\n"
;
81
#else
82
std::cout <<
" container_system: not linked\n"
;
83
#endif
84
85
// 3. Conditional compilation example
86
std::cout <<
"\n3. Conditional compilation patterns:\n"
;
87
88
#if KCENON_HAS_SOURCE_LOCATION
89
auto
loc = std::source_location::current();
90
std::cout <<
" Called from: "
<< loc.file_name() <<
":"
<< loc.line() <<
"\n"
;
91
#else
92
std::cout <<
" Source location: using fallback (__FILE__:__LINE__)\n"
;
93
std::cout <<
" Called from: "
<< __FILE__ <<
":"
<< __LINE__ <<
"\n"
;
94
#endif
95
96
// 4. Platform detection
97
std::cout <<
"\n4. Platform:\n"
;
98
#if defined(_WIN32) || defined(_WIN64)
99
std::cout <<
" OS: Windows\n"
;
100
#elif defined(__APPLE__)
101
std::cout <<
" OS: macOS\n"
;
102
#elif defined(__linux__)
103
std::cout <<
" OS: Linux\n"
;
104
#else
105
std::cout <<
" OS: Unknown\n"
;
106
#endif
107
108
std::cout <<
"\nDone.\n"
;
109
return
0;
110
}
main
int main()
Definition
abi_version_example.cpp:20
feature_flags.h
Unified feature flags header for common_system.
yes_no
constexpr const char * yes_no(bool v)
Definition
feature_flags_example.cpp:25
examples
feature_flags_example.cpp
Generated by
1.12.0