Skip to content

Commit c5b0155

Browse files
committed
Apply clang-format.
1 parent 1cdc023 commit c5b0155

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

include/ext/logging.hpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@
3131
// helper
3232
#define _EXT_LOG_SELECT5TH_PARAMETER(_1, _2, _3, _4, NAME, ...) NAME
3333

34+
// __VA_ARGS__ do not expand correctly when using VisualStudio compiler :(
35+
// https://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly
36+
#define _EXT_LOG_EXPAND(x) x
3437

3538
// variable logging - if() ...
36-
#define _EXT_LOG_INTERNAL(id_, topic_, macro_level_, cond_) \
39+
#define _EXT_LOG_INTERNAL(id_, topic_, macro_level_, cond_) \
3740
if (ext::logging::_detail::variable_level_is_active((macro_level_), (topic_)) && cond_) \
3841
ext::logging::_detail::logger(id_, (topic_), (macro_level_), __FILE__, __LINE__, __FUNCTION__)
3942

@@ -48,14 +51,14 @@
4851
// 1st __VA_ARGS__ shifts the args into the correct position
4952
// macro can not be empty because of the leading `,` (fixed with __VA_OPT__ in c++20)
5053
#ifdef EXT_COMPILER_VC
51-
// __VA_ARGS__ does not expand on VisualStudio compiler :(
52-
#define _EXT_LOG_EXPAND(x) x
53-
#define EXT_LOGVARIABLE(...) \
54-
_EXT_LOG_SELECT5TH_PARAMETER(_EXT_LOG_EXPAND(__VA_ARGS__), EXT_LOGVARIABLE4, EXT_LOGVARIABLE3, EXT_LOGVARIABLE2, EXT_LOGVARIABLE1, ) \
54+
#define EXT_LOGVARIABLE(...) \
55+
_EXT_LOG_SELECT5TH_PARAMETER( \
56+
_EXT_LOG_EXPAND(__VA_ARGS__), EXT_LOGVARIABLE4, EXT_LOGVARIABLE3, EXT_LOGVARIABLE2, EXT_LOGVARIABLE1, ) \
5557
(_EXT_LOG_EXPAND(__VA_ARGS__))
5658
#else
57-
#define EXT_LOGVARIABLE(...) \
58-
_EXT_LOG_SELECT5TH_PARAMETER(__VA_ARGS__, EXT_LOGVARIABLE4, EXT_LOGVARIABLE3, EXT_LOGVARIABLE2, EXT_LOGVARIABLE1, ) \
59+
#define EXT_LOGVARIABLE(...) \
60+
_EXT_LOG_SELECT5TH_PARAMETER( \
61+
__VA_ARGS__, EXT_LOGVARIABLE4, EXT_LOGVARIABLE3, EXT_LOGVARIABLE2, EXT_LOGVARIABLE1, ) \
5962
(__VA_ARGS__)
6063
#endif // EXT_COMPILER_VC
6164

@@ -64,13 +67,10 @@
6467
#define EXT_LOG EXT_LOGVARIABLE
6568

6669

67-
// This is still a bit experimental:
68-
// constexpr if() does not seem to work in a macro is there some way that guarantees the evaluation
69-
// at compile time. Otherwise it would be better to remove this code in order to reduce the complexity.
70-
71-
#define _EXT_LOG_INTERNAL_CONST(id_, topic_, macro_level_, cond_) \
72-
if constexpr (ext::logging::_detail::constexpr_level_is_active(macro_level_) && cond_) \
73-
ext::logging::_detail::logger(id_, (topic_), (macro_level_), __FILE__, __LINE__, __FUNCTION__)
70+
// variable logging - if constexpr() ...
71+
#define _EXT_LOG_INTERNAL_CONST(id_, topic_, macro_level_, cond_) \
72+
if constexpr (ext::logging::_detail::constexpr_level_is_active(macro_level_) && cond_) \
73+
ext::logging::_detail::logger(id_, (topic_), (macro_level_), __FILE__, __LINE__, __FUNCTION__)
7474

7575
#define _EXT_LOG_INTERNAL_ADD_PREFIX_CONST(id_, topic_, macro_level_, cond_) \
7676
_EXT_LOG_INTERNAL_CONST(id_, (ext::logging::topic::topic_), (ext::logging::level::macro_level_), cond_)
@@ -81,12 +81,12 @@
8181
#define EXT_LOGCONST1(id) _EXT_LOG_INTERNAL_ADD_PREFIX_CONST(id, no_topic, EXT_LOGGING_DEFAULT_LEVEL, true)
8282

8383
#ifdef EXT_COMPILER_VC
84-
#define _EXT_LOG_EXPAND(x) x
85-
#define EXT_LOGCONST(...) \
86-
_EXT_LOG_SELECT5TH_PARAMETER(_EXT_LOG_EXPAND(__VA_ARGS__), EXT_LOGCONST4, EXT_LOGCONST3, EXT_LOGCONST2, EXT_LOGCONST1, ) \
84+
#define EXT_LOGCONST(...) \
85+
_EXT_LOG_SELECT5TH_PARAMETER( \
86+
_EXT_LOG_EXPAND(__VA_ARGS__), EXT_LOGCONST4, EXT_LOGCONST3, EXT_LOGCONST2, EXT_LOGCONST1, ) \
8787
(_EXT_LOG_EXPAND(__VA_ARGS__))
8888
#else
89-
#define EXT_LOGCONST(...) \
89+
#define EXT_LOGCONST(...) \
9090
_EXT_LOG_SELECT5TH_PARAMETER(__VA_ARGS__, EXT_LOGCONST4, EXT_LOGCONST3, EXT_LOGCONST2, EXT_LOGCONST1, ) \
9191
(__VA_ARGS__)
9292
#endif // EXT_COMPILER_VC

0 commit comments

Comments
 (0)