emilk / loguru

A lightweight C++ logging library
The Unlicense
1.76k stars 256 forks source link

Fixed compilation errors during macro expansion by vs2022 #237

Open cyrilcourvoisier opened 1 year ago

cyrilcourvoisier commented 1 year ago

On Visual Studio 2022 compiler, the macro expansion of DLOG_IF_F fails for some reasons. __VA_ARGS__ is expanded into 'cond' variable of the VLOG_IF macro and : loguru::log() only got three arguments.

define VLOG_IF_F(verbosity, cond, ...) \

((verbosity) > loguru::current_verbosity_cutoff() || (cond) == false)                          \
    ? (void)0                                                                                  \
    : loguru::log(verbosity, __FILE__, __LINE__, __VA_ARGS__) 

I have added 'cond' parameter to DLOG_IF_F and DVLOG_IF_F so the signature maps correctly with VLOG_IF_F and it fixes the problem.