IRSOL
C++ code implementing socket server for interacting with Baumer camera.
macros.hpp
Go to the documentation of this file.
1
13#pragma once
14
15#include "irsol/assert.hpp"
16#include "irsol/traits.hpp"
17
32#if defined(__cplusplus) && __cplusplus >= 201703L
33#define IRSOL_MAYBE_UNUSED [[maybe_unused]]
34#elif defined(__GNUC__) || defined(__clang__)
35#define IRSOL_MAYBE_UNUSED __attribute__((unused))
36#elif defined(_MSC_VER)
37#define IRSOL_MAYBE_UNUSED
38#else
39#define IRSOL_MAYBE_UNUSED
40#endif
41
59#if defined(__GNUC__) || defined(__clang__)
60#ifndef IRSOL_SUPPRESS_UNUSED_STRUCTURED_BINDING_START
61#define IRSOL_SUPPRESS_UNUSED_STRUCTURED_BINDING_START \
62 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
63#endif
64#ifndef IRSOL_SUPPRESS_UNUSED_STRUCTURED_BINDING_END
65#define IRSOL_SUPPRESS_UNUSED_STRUCTURED_BINDING_END _Pragma("GCC diagnostic pop")
66#endif
67#else
68#define IRSOL_SUPPRESS_UNUSED_STRUCTURED_BINDING_START
69#define IRSOL_SUPPRESS_UNUSED_STRUCTURED_BINDING_END
70#endif
71
79#if defined(__GNUC__) || defined(__clang__)
80#define _IRSOL_UNREACHABLE_IMPL() __builtin_unreachable()
81#elif defined(_MSC_VER)
82#define _IRSOL_UNREACHABLE_IMPL() __assume(false)
83#else
84#define _IRSOL_UNREACHABLE_IMPL() \
85 do { \
86 } while(0)
87#endif
88
107#define IRSOL_UNREACHABLE() _IRSOL_UNREACHABLE_IMPL()
108
129#ifndef IRSOL_STATIC_UNREACHABLE
130#define IRSOL_STATIC_UNREACHABLE(messageLiteral) \
131 IRSOL_STATIC_ASSERT( \
132 (irsol::traits::always_false<struct _irsol_dependent_false_>::value), \
133 "Unreachable constexpr code triggered: " messageLiteral); \
134 _IRSOL_UNREACHABLE_IMPL()
135#endif
136
147#ifndef _IRSOL_STATIC_ASSERT_MISSING_TEMPLATE_SPECIALIZATION
148#define _IRSOL_STATIC_ASSERT_MISSING_TEMPLATE_SPECIALIZATION(T, messageLiteral) \
149 IRSOL_STATIC_ASSERT((irsol::traits::always_false<T>::value), messageLiteral)
150#endif
151
172#ifndef IRSOL_MISSING_TEMPLATE_SPECIALIZATION
173#define IRSOL_MISSING_TEMPLATE_SPECIALIZATION(T, funcNameLiteral) \
174 _IRSOL_STATIC_ASSERT_MISSING_TEMPLATE_SPECIALIZATION( \
175 T, \
176 "Function '" funcNameLiteral "' lacks a template specialization for this type. " \
177 "Please ensure you handle all required template types explicitly.")
178#endif
Assertion macros and utilities based on the PPK_ASSERT library.
Template metaprogramming traits for type introspection in the irsol library.