diff --git a/src/logging/timer.h b/src/logging/timer.h --- a/src/logging/timer.h +++ b/src/logging/timer.h @@ -92,17 +92,16 @@ } // namespace BCLog #define LOG_TIME_MICROS_WITH_CATEGORY(end_msg, log_category) \ - BCLog::Timer PASTE2( \ - logging_timer, __COUNTER__)(__func__, end_msg, log_category) + BCLog::Timer UNIQUE_NAME(logging_timer)( \ + __func__, end_msg, log_category) #define LOG_TIME_MILLIS_WITH_CATEGORY(end_msg, log_category) \ - BCLog::Timer PASTE2( \ - logging_timer, __COUNTER__)(__func__, end_msg, log_category) + BCLog::Timer UNIQUE_NAME(logging_timer)( \ + __func__, end_msg, log_category) #define LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE(end_msg, log_category) \ - BCLog::Timer PASTE2( \ - logging_timer, __COUNTER__)(__func__, end_msg, log_category, \ - /* msg_on_completion=*/false) + BCLog::Timer UNIQUE_NAME(logging_timer)( \ + __func__, end_msg, log_category, /* msg_on_completion=*/false) #define LOG_TIME_SECONDS(end_msg) \ - BCLog::Timer PASTE2(logging_timer, \ - __COUNTER__)(__func__, end_msg) + BCLog::Timer UNIQUE_NAME(logging_timer)(__func__, \ + end_msg) #endif // BITCOIN_LOGGING_TIMER_H diff --git a/src/sync.h b/src/sync.h --- a/src/sync.h +++ b/src/sync.h @@ -246,16 +246,16 @@ }; #define REVERSE_LOCK(g) \ - typename std::decay::type::reverse_lock PASTE2( \ - revlock, __COUNTER__)(g, #g, __FILE__, __LINE__) + typename std::decay::type::reverse_lock UNIQUE_NAME(revlock)( \ + g, #g, __FILE__, __LINE__) template using DebugLock = UniqueLock::type>::type>; #define LOCK(cs) \ - DebugLock PASTE2(criticalblock, \ - __COUNTER__)(cs, #cs, __FILE__, __LINE__) + DebugLock UNIQUE_NAME(criticalblock)(cs, #cs, __FILE__, \ + __LINE__) #define LOCK2(cs1, cs2) \ DebugLock criticalblock1(cs1, #cs1, __FILE__, __LINE__); \ DebugLock criticalblock2(cs2, #cs2, __FILE__, __LINE__); diff --git a/src/test/util/logging.h b/src/test/util/logging.h --- a/src/test/util/logging.h +++ b/src/test/util/logging.h @@ -39,6 +39,6 @@ }; #define ASSERT_DEBUG_LOG(message) \ - DebugLogHelper PASTE2(debugloghelper, __COUNTER__)(message) + DebugLogHelper UNIQUE_NAME(debugloghelper)(message) #endif // BITCOIN_TEST_UTIL_LOGGING_H diff --git a/src/util/epochguard.h b/src/util/epochguard.h --- a/src/util/epochguard.h +++ b/src/util/epochguard.h @@ -7,6 +7,7 @@ #define BITCOIN_UTIL_EPOCHGUARD_H #include +#include #include @@ -94,6 +95,6 @@ }; #define WITH_FRESH_EPOCH(epoch) \ - const Epoch::Guard PASTE2(epoch_guard_, __COUNTER__)(epoch) + const Epoch::Guard UNIQUE_NAME(epoch_guard_)(epoch) #endif // BITCOIN_UTIL_EPOCHGUARD_H diff --git a/src/util/macros.h b/src/util/macros.h --- a/src/util/macros.h +++ b/src/util/macros.h @@ -8,6 +8,8 @@ #define PASTE(x, y) x##y #define PASTE2(x, y) PASTE(x, y) +#define UNIQUE_NAME(name) PASTE2(name, __COUNTER__) + /** * Converts the parameter X to a string after macro replacement on X has been * performed.