mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
Codechange: Use __VA_OPT__(,)
instead of , ##
(#12921)
`__VA_OPT__` is a C++20 standard, `##` is, apparently, a GNU extension. MSVC needs /Zc:preprocessor adding for whatever reason.
This commit is contained in:
parent
7f5a3eaf83
commit
ad5da0c924
@ -8,6 +8,9 @@ macro(compile_flags)
|
|||||||
# C++11 standard". We need C++11 for the way we use threads.
|
# C++11 standard". We need C++11 for the way we use threads.
|
||||||
add_compile_options(/Zc:rvalueCast)
|
add_compile_options(/Zc:rvalueCast)
|
||||||
|
|
||||||
|
# Needed for __VA_OPT__() in macros.
|
||||||
|
add_compile_options(/Zc:preprocessor)
|
||||||
|
|
||||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
/MP # Enable multi-threaded compilation.
|
/MP # Enable multi-threaded compilation.
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
* @param level The maximum debug level this message should be shown at. When the debug level for this category is set lower, then the message will not be shown.
|
* @param level The maximum debug level this message should be shown at. When the debug level for this category is set lower, then the message will not be shown.
|
||||||
* @param format_string The formatting string of the message.
|
* @param format_string The formatting string of the message.
|
||||||
*/
|
*/
|
||||||
#define Debug(category, level, format_string, ...) do { if ((level) == 0 || _debug_ ## category ## _level >= (level)) DebugPrint(#category, level, fmt::format(FMT_STRING(format_string), ## __VA_ARGS__)); } while (false)
|
#define Debug(category, level, format_string, ...) do { if ((level) == 0 || _debug_ ## category ## _level >= (level)) DebugPrint(#category, level, fmt::format(FMT_STRING(format_string) __VA_OPT__(,) __VA_ARGS__)); } while (false)
|
||||||
void DebugPrint(const char *category, int level, const std::string &message);
|
void DebugPrint(const char *category, int level, const std::string &message);
|
||||||
|
|
||||||
extern int _debug_driver_level;
|
extern int _debug_driver_level;
|
||||||
@ -93,7 +93,7 @@ struct TicToc {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void ShowInfoI(const std::string &str);
|
void ShowInfoI(const std::string &str);
|
||||||
#define ShowInfo(format_string, ...) ShowInfoI(fmt::format(FMT_STRING(format_string), ## __VA_ARGS__))
|
#define ShowInfo(format_string, ...) ShowInfoI(fmt::format(FMT_STRING(format_string) __VA_OPT__(,) __VA_ARGS__))
|
||||||
|
|
||||||
std::string GetLogPrefix(bool force = false);
|
std::string GetLogPrefix(bool force = false);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
[[noreturn]] void UserErrorI(const std::string &str);
|
[[noreturn]] void UserErrorI(const std::string &str);
|
||||||
[[noreturn]] void FatalErrorI(const std::string &str);
|
[[noreturn]] void FatalErrorI(const std::string &str);
|
||||||
#define UserError(format_string, ...) UserErrorI(fmt::format(FMT_STRING(format_string), ## __VA_ARGS__))
|
#define UserError(format_string, ...) UserErrorI(fmt::format(FMT_STRING(format_string) __VA_OPT__(,) __VA_ARGS__))
|
||||||
#define FatalError(format_string, ...) FatalErrorI(fmt::format(FMT_STRING(format_string), ## __VA_ARGS__))
|
#define FatalError(format_string, ...) FatalErrorI(fmt::format(FMT_STRING(format_string) __VA_OPT__(,) __VA_ARGS__))
|
||||||
|
|
||||||
#endif /* ERROR_FUNC_H */
|
#endif /* ERROR_FUNC_H */
|
||||||
|
@ -202,7 +202,7 @@ void ResetNewGRFData();
|
|||||||
void ResetPersistentNewGRFData();
|
void ResetPersistentNewGRFData();
|
||||||
|
|
||||||
void GrfMsgI(int severity, const std::string &msg);
|
void GrfMsgI(int severity, const std::string &msg);
|
||||||
#define GrfMsg(severity, format_string, ...) do { if ((severity) == 0 || _debug_grf_level >= (severity)) GrfMsgI(severity, fmt::format(FMT_STRING(format_string), ## __VA_ARGS__)); } while (false)
|
#define GrfMsg(severity, format_string, ...) do { if ((severity) == 0 || _debug_grf_level >= (severity)) GrfMsgI(severity, fmt::format(FMT_STRING(format_string) __VA_OPT__(,) __VA_ARGS__)); } while (false)
|
||||||
|
|
||||||
bool GetGlobalVariable(uint8_t param, uint32_t *value, const GRFFile *grffile);
|
bool GetGlobalVariable(uint8_t param, uint32_t *value, const GRFFile *grffile);
|
||||||
|
|
||||||
|
@ -150,9 +150,9 @@ ParsedCommandStruct ExtractCommandString(const char *s, bool warnings);
|
|||||||
void StrgenWarningI(const std::string &msg);
|
void StrgenWarningI(const std::string &msg);
|
||||||
void StrgenErrorI(const std::string &msg);
|
void StrgenErrorI(const std::string &msg);
|
||||||
[[noreturn]] void StrgenFatalI(const std::string &msg);
|
[[noreturn]] void StrgenFatalI(const std::string &msg);
|
||||||
#define StrgenWarning(format_string, ...) StrgenWarningI(fmt::format(FMT_STRING(format_string), ## __VA_ARGS__))
|
#define StrgenWarning(format_string, ...) StrgenWarningI(fmt::format(FMT_STRING(format_string) __VA_OPT__(,) __VA_ARGS__))
|
||||||
#define StrgenError(format_string, ...) StrgenErrorI(fmt::format(FMT_STRING(format_string), ## __VA_ARGS__))
|
#define StrgenError(format_string, ...) StrgenErrorI(fmt::format(FMT_STRING(format_string) __VA_OPT__(,) __VA_ARGS__))
|
||||||
#define StrgenFatal(format_string, ...) StrgenFatalI(fmt::format(FMT_STRING(format_string), ## __VA_ARGS__))
|
#define StrgenFatal(format_string, ...) StrgenFatalI(fmt::format(FMT_STRING(format_string) __VA_OPT__(,) __VA_ARGS__))
|
||||||
char *ParseWord(char **buf);
|
char *ParseWord(char **buf);
|
||||||
|
|
||||||
extern const char *_file;
|
extern const char *_file;
|
||||||
|
Loading…
Reference in New Issue
Block a user