Use __VA_OPT__(, ) __VA_ARGS__ instead of ##__VA_ARGS__

Per https://en.cppreference.com/w/cpp/preprocessor/replace#.23_and_.23.23_operators the `##` behavior is a nonstandard extension; this extension seems to be supported by all compilers we care about, but IntelliSense in visual studio doesn't correctly handle it, resulting in false errors in the IDE (but not when compiling).

Per https://en.cppreference.com/w/cpp/preprocessor/replace#Function-like_macros C++20 introduced a workaround, where `__VA_OPT__(, )` generates a comma if and only if `__VA_ARGS__` is non-empty.

This PR replaces all occurrences, with the exception of Externals, DSPSpy (which is not likely to be edited in MSVC and does not target C++20 currently), and JitArm64_Integer.cpp (which uses `Function(__VA_ARGS__)`, and thus does not ever need a comma).
This commit is contained in:
Pokechu22
2022-08-23 11:14:47 -07:00
parent 0fcff9f5ea
commit 0cced44142
5 changed files with 32 additions and 25 deletions

View File

@ -84,46 +84,48 @@ std::string FmtFormatT(const char* string, Args&&... args)
#define GenericAlertFmt(yes_no, style, log_type, format, ...) \
Common::MsgAlertFmt<Common::CountFmtReplacementFields(format)>( \
yes_no, style, Common::Log::LogType::log_type, __FILE__, __LINE__, FMT_STRING(format), \
##__VA_ARGS__)
yes_no, style, Common::Log::LogType::log_type, __FILE__, __LINE__, \
FMT_STRING(format) __VA_OPT__(, ) __VA_ARGS__)
#define GenericAlertFmtT(yes_no, style, log_type, format, ...) \
Common::MsgAlertFmtT<Common::CountFmtReplacementFields(format), \
Common::ContainsNonPositionalArguments(format)>( \
yes_no, style, Common::Log::LogType::log_type, __FILE__, __LINE__, FMT_STRING(format), \
Common::GetStringT(format), ##__VA_ARGS__)
Common::GetStringT(format) __VA_OPT__(, ) __VA_ARGS__)
#define SuccessAlertFmt(format, ...) \
GenericAlertFmt(false, Common::MsgType::Information, MASTER_LOG, format, ##__VA_ARGS__)
GenericAlertFmt(false, Common::MsgType::Information, MASTER_LOG, \
format __VA_OPT__(, ) __VA_ARGS__)
#define PanicAlertFmt(format, ...) \
GenericAlertFmt(false, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__)
GenericAlertFmt(false, Common::MsgType::Warning, MASTER_LOG, format __VA_OPT__(, ) __VA_ARGS__)
#define PanicYesNoFmt(format, ...) \
GenericAlertFmt(true, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__)
GenericAlertFmt(true, Common::MsgType::Warning, MASTER_LOG, format __VA_OPT__(, ) __VA_ARGS__)
#define AskYesNoFmt(format, ...) \
GenericAlertFmt(true, Common::MsgType::Question, MASTER_LOG, format, ##__VA_ARGS__)
GenericAlertFmt(true, Common::MsgType::Question, MASTER_LOG, format __VA_OPT__(, ) __VA_ARGS__)
#define CriticalAlertFmt(format, ...) \
GenericAlertFmt(false, Common::MsgType::Critical, MASTER_LOG, format, ##__VA_ARGS__)
GenericAlertFmt(false, Common::MsgType::Critical, MASTER_LOG, format __VA_OPT__(, ) __VA_ARGS__)
// Use these macros (that do the same thing) if the message should be translated.
#define SuccessAlertFmtT(format, ...) \
GenericAlertFmtT(false, Common::MsgType::Information, MASTER_LOG, format, ##__VA_ARGS__)
GenericAlertFmtT(false, Common::MsgType::Information, MASTER_LOG, \
format __VA_OPT__(, ) __VA_ARGS__)
#define PanicAlertFmtT(format, ...) \
GenericAlertFmtT(false, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__)
GenericAlertFmtT(false, Common::MsgType::Warning, MASTER_LOG, format __VA_OPT__(, ) __VA_ARGS__)
#define PanicYesNoFmtT(format, ...) \
GenericAlertFmtT(true, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__)
GenericAlertFmtT(true, Common::MsgType::Warning, MASTER_LOG, format __VA_OPT__(, ) __VA_ARGS__)
#define AskYesNoFmtT(format, ...) \
GenericAlertFmtT(true, Common::MsgType::Question, MASTER_LOG, format, ##__VA_ARGS__)
GenericAlertFmtT(true, Common::MsgType::Question, MASTER_LOG, format __VA_OPT__(, ) __VA_ARGS__)
#define CriticalAlertFmtT(format, ...) \
GenericAlertFmtT(false, Common::MsgType::Critical, MASTER_LOG, format, ##__VA_ARGS__)
GenericAlertFmtT(false, Common::MsgType::Critical, MASTER_LOG, format __VA_OPT__(, ) __VA_ARGS__)
// Variant that takes a log type, used by the assert macros
#define PanicYesNoFmtAssert(log_type, format, ...) \
GenericAlertFmt(true, Common::MsgType::Warning, log_type, format, ##__VA_ARGS__)
GenericAlertFmt(true, Common::MsgType::Warning, log_type, format __VA_OPT__(, ) __VA_ARGS__)