@@ -190,6 +190,7 @@ static constexpr std::size_t skipPathPrefix(const char (&s)[N], std::size_t n =
190190// so we need an indirection to expand macros before using the result.
191191#define CONCATINATE_IMPL (X, Y ) X##Y
192192#define CONCATINATE (X, Y ) CONCATINATE_IMPL(X, Y)
193+ #define UNIQUE_VAR (X ) CONCATINATE(X, __LINE__)
193194#define STRINGIFY (X ) #X
194195#define STRING (X ) STRINGIFY(X)
195196
@@ -226,23 +227,23 @@ static constexpr std::size_t skipPathPrefix(const char (&s)[N], std::size_t n =
226227 } \
227228 } while (false )
228229
229-
230- #define LOG_BODY_ (LVL, X, PREFIX, END ) \
231- char b_[1024 ]; \
232- std::ostringstream oss_ ( \
233- Log::prefix<sizeof (b_) - 1>(b_, #LVL), \
234- std::ostringstream::ate); \
235- PREFIX (oss_); \
236- oss_ << std::boolalpha << X; \
237- END (oss_); \
230+ #define LOG_BODY_ (LVL, X, PREFIX, END ) \
231+ char UNIQUE_VAR (buffer)[1024]; \
232+ std::ostringstream oss_ (Log::prefix<sizeof (UNIQUE_VAR(buffer)) - 1>(UNIQUE_VAR(buffer), #LVL), \
233+ std::ostringstream::ate); \
234+ PREFIX (oss_); \
235+ oss_ << std::boolalpha << X; \
236+ END (oss_); \
238237 LOG_LOG (LVL, oss_.str())
239238
240239// / Unconditionally log. LVL can be anything converted to string.
241240#define LOG_UNCONDITIONAL (LVL, X ) \
242241 do \
243242 { \
244- char b_[1024 ]; \
245- std::ostringstream oss_ (Log::prefix<sizeof (b_) - 1 >(b_, #LVL), std::ostringstream::ate); \
243+ char UNIQUE_VAR (buffer)[1024 ]; \
244+ std::ostringstream oss_ ( \
245+ Log::prefix<sizeof (UNIQUE_VAR (buffer)) - 1 >(UNIQUE_VAR (buffer), #LVL), \
246+ std::ostringstream::ate); \
246247 logPrefix (oss_); \
247248 oss_ << std::boolalpha << X; \
248249 LOG_END (oss_); \
@@ -357,14 +358,14 @@ static constexpr std::size_t skipPathPrefix(const char (&s)[N], std::size_t n =
357358#define LOG_ASSERT_INTERNAL (condition, message, LOG ) \
358359 do \
359360 { \
360- auto && CONCATINATE (cond, __LINE__ ) = !!(condition); \
361- if (!CONCATINATE (cond, __LINE__)) \
361+ auto && UNIQUE_VAR (cond) = !!(condition); \
362+ if (!UNIQUE_VAR (cond)) \
362363 { \
363- std::ostringstream CONCATINATE (oss, __LINE__); \
364- CONCATINATE (oss, __LINE__ ) << message; \
365- const auto CONCATINATE (msg, __LINE__ ) = CONCATINATE (oss, __LINE__ ).str (); \
364+ std::ostringstream UNIQUE_VAR (oss); \
365+ UNIQUE_VAR (oss) << message; \
366+ const auto UNIQUE_VAR (msg) = UNIQUE_VAR (oss).str (); \
366367 LOG (" ERROR: Assertion failure: " \
367- << (CONCATINATE (msg, __LINE__ ).empty () ? " " : CONCATINATE (msg, __LINE__ ) + " . " ) \
368+ << (UNIQUE_VAR (msg).empty () ? " " : UNIQUE_VAR (msg) + " . " ) \
368369 << " Condition: " << STRING (condition)); \
369370 assert (!STRING (condition)); /* NOLINT(misc-static-assert) */ \
370371 } \
0 commit comments