Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
abi_version_example.cpp
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
15
16#include <kcenon/common/config/abi_version.h>
17#include <iostream>
18#include <iomanip>
19
20int main() {
21 using namespace kcenon::common::abi;
22
23 std::cout << "=== common_system ABI Information ===\n\n";
24
25 // Display version components
26 std::cout << "Version: " << version_string << "\n";
27 std::cout << "Version (hex): 0x"
28 << std::hex << std::setw(8) << std::setfill('0') << version << "\n";
29 std::cout << std::dec;
30 std::cout << "Major: " << version_major << "\n";
31 std::cout << "Minor: " << version_minor << "\n";
32 std::cout << "Patch: " << version_patch << "\n";
33 std::cout << "\n";
34
35 // Display ABI-specific versions
36 std::cout << "Event Bus ABI Version: " << event_bus_version << "\n";
37 std::cout << "\n";
38
39 // Display build information
40 std::cout << "Build Type: " << build_type << "\n";
41 std::cout << "Build Timestamp: " << build_timestamp << "\n";
42 std::cout << "\n";
43
44 // Compile-time ABI checking example
45 std::cout << "=== ABI Compatibility Checks ===\n\n";
46
47 // This will compile successfully (version matches)
48 abi_checker<0x00010000> version_check;
49 std::cout << "✓ Compile-time check passed for version 0x00010000\n";
50
51 // Runtime version checking
52 uint32_t required_version = 0x00010000; // 1.0.0
53 if (check_abi_version(required_version)) {
54 std::cout << "✓ Runtime version check passed\n";
55 } else {
56 std::cout << "✗ Runtime version check failed\n";
57 }
58
59 // Compatibility checking
60 if (is_compatible(0x00010000)) {
61 std::cout << "✓ Compatible with version 1.0.0\n";
62 }
63
64 if (is_compatible(0x00000100)) {
65 std::cout << "✓ Compatible with version 0.1.0\n";
66 } else {
67 std::cout << "✗ Not compatible with version 0.1.0 (major version mismatch)\n";
68 }
69
70 std::cout << "\n";
71
72 // Link-time symbol check
73 std::cout << "=== Link-Time ABI Signature ===\n\n";
74 std::cout << "ABI Signature: " << get_abi_signature() << "\n";
75
76 return 0;
77}
int main()