diff --git a/src/common/small_string.h b/src/common/small_string.h index 799e03a13..16dfe507a 100644 --- a/src/common/small_string.h +++ b/src/common/small_string.h @@ -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 @@ -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 @@ -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 @@ -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 static SmallStackString from_format(fmt::format_string fmt, T&&... args); diff --git a/src/common/types.h b/src/common/types.h index f2a6c759f..2f22d8a0b 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -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. diff --git a/src/core/cpu_core.h b/src/core/cpu_core.h index 566a30944..708410ee3 100644 --- a/src/core/cpu_core.h +++ b/src/core/cpu_core.h @@ -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();