Skip to content

Commit 1b92c5d

Browse files
logging: add proper checks for clang to avoid errors and warnings with VA_ARGS
1 parent af0a5b6 commit 1b92c5d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

common/log.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ inline std::string log_filename_generator_impl(LogTriState multilog, const std::
211211
#define LOG_FLF_VAL , __FILE__, __LINE__, __FUNCTION__
212212
#else
213213
#define LOG_FLF_FMT "[%24s:%5ld][%24s] "
214-
#define LOG_FLF_VAL , __FILE__, __LINE__, __FUNCTION__
214+
#define LOG_FLF_VAL , __FILE__, (long)__LINE__, __FUNCTION__
215215
#endif
216216
#else
217217
#define LOG_FLF_FMT "%s"
@@ -224,7 +224,7 @@ inline std::string log_filename_generator_impl(LogTriState multilog, const std::
224224
#define LOG_TEE_FLF_VAL , __FILE__, __LINE__, __FUNCTION__
225225
#else
226226
#define LOG_TEE_FLF_FMT "[%24s:%5ld][%24s] "
227-
#define LOG_TEE_FLF_VAL , __FILE__, __LINE__, __FUNCTION__
227+
#define LOG_TEE_FLF_VAL , __FILE__, (long)__LINE__, __FUNCTION__
228228
#endif
229229
#else
230230
#define LOG_TEE_FLF_FMT "%s"
@@ -294,7 +294,7 @@ inline std::string log_filename_generator_impl(LogTriState multilog, const std::
294294
// Main LOG macro.
295295
// behaves like printf, and supports arguments the exact same way.
296296
//
297-
#ifndef _MSC_VER
297+
#if !defined(_MSC_VER) || defined(__clang__)
298298
#define LOG(...) LOG_IMPL(__VA_ARGS__, "")
299299
#else
300300
#define LOG(str, ...) LOG_IMPL("%s" str, "", ##__VA_ARGS__, "")
@@ -308,14 +308,14 @@ inline std::string log_filename_generator_impl(LogTriState multilog, const std::
308308
// Secondary target can be changed just like LOG_TARGET
309309
// by defining LOG_TEE_TARGET
310310
//
311-
#ifndef _MSC_VER
311+
#if !defined(_MSC_VER) || defined(__clang__)
312312
#define LOG_TEE(...) LOG_TEE_IMPL(__VA_ARGS__, "")
313313
#else
314314
#define LOG_TEE(str, ...) LOG_TEE_IMPL("%s" str, "", ##__VA_ARGS__, "")
315315
#endif
316316

317317
// LOG macro variants with auto endline.
318-
#ifndef _MSC_VER
318+
#if !defined(_MSC_VER) || defined(__clang__)
319319
#define LOGLN(...) LOG_IMPL(__VA_ARGS__, "\n")
320320
#define LOG_TEELN(...) LOG_TEE_IMPL(__VA_ARGS__, "\n")
321321
#else

0 commit comments

Comments
 (0)