Common: Allow PRINTFLIKE to work on Clang

And thus clang-cl.
This commit is contained in:
Stenzek 2024-09-18 21:31:06 +10:00
parent 8ba85d62dc
commit 401295ebdb
No known key found for this signature in database
3 changed files with 12 additions and 10 deletions

View File

@ -60,7 +60,7 @@ public:
void append(const SmallStringBase& str);
// append formatted string to this string
void append_sprintf(const char* format, ...) printflike(2, 3);
void append_sprintf(const char* format, ...) PRINTFLIKE(2, 3);
void append_vsprintf(const char* format, va_list ap);
template<typename... T>
@ -80,7 +80,7 @@ public:
void prepend(const SmallStringBase& str);
// append formatted string to this string
void prepend_sprintf(const char* format, ...) printflike(2, 3);
void prepend_sprintf(const char* format, ...) PRINTFLIKE(2, 3);
void prepend_vsprintf(const char* format, va_list ap);
template<typename... T>
@ -94,7 +94,7 @@ public:
void insert(s32 offset, const SmallStringBase& str);
// set to formatted string
void sprintf(const char* format, ...) printflike(2, 3);
void sprintf(const char* format, ...) PRINTFLIKE(2, 3);
void vsprintf(const char* format, va_list ap);
template<typename... T>
@ -333,7 +333,7 @@ public:
}
// Override the fromstring method
static SmallStackString from_sprintf(const char* format, ...) printflike(1, 2);
static SmallStackString from_sprintf(const char* format, ...) PRINTFLIKE(1, 2);
template<typename... T>
static SmallStackString from_format(fmt::format_string<T...> fmt, T&&... args);

View File

@ -56,19 +56,21 @@ char (&__countof_ArraySizeHelper(T (&array)[N]))[N];
// offsetof macro. Need to use __builtin_offsetof(), otherwise it doesn't work in constant expressions.
#if defined(__clang__) || defined(__GNUC__)
#define OFFSETOF(st, m) __builtin_offsetof(st, m)
#define PRINTFLIKE(n, m) __attribute__((format(printf, n, m)))
#else
#ifdef offsetof
#define OFFSETOF(st, m) offsetof(st, m)
#else
#define OFFSETOF(st, m) ((size_t)((char*)&((st*)(0))->m - (char*)0))
#endif
#endif
#ifdef __GNUC__
#define printflike(n, m) __attribute__((format(printf, n, m)))
#else
#define printflike(n, m)
#define PRINTFLIKE(n, m)
#endif
// [[noreturn]] which can be used on function pointers.

View File

@ -193,7 +193,7 @@ void DisassembleAndLog(u32 addr);
void DisassembleAndPrint(u32 addr, u32 instructions_before, u32 instructions_after);
// Write to CPU execution log file.
void WriteToExecutionLog(const char* format, ...) printflike(1, 2);
void WriteToExecutionLog(const char* format, ...) PRINTFLIKE(1, 2);
// Trace Routines
bool IsTraceEnabled();