From 0c91b1e613a728351d03ac5018ea344495548e14 Mon Sep 17 00:00:00 2001 From: "C.W. Betts" Date: Mon, 26 Feb 2018 15:28:28 -0700 Subject: [PATCH] Add printf-like macros to MVKLogImpl and mvkNotifyErrorWithText. This will make the compiler point out improper formatting of variadic functions. --- Common/MVKLogging.h | 2 ++ MoltenVK/MoltenVK/Utility/MVKFoundation.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Common/MVKLogging.h b/Common/MVKLogging.h index 3295cdcc..5ab2c70d 100755 --- a/Common/MVKLogging.h +++ b/Common/MVKLogging.h @@ -176,6 +176,7 @@ extern "C" { * Combine the specified log level and format string, then log * the specified args to one or both of ASL and printf. */ +static inline void MVKLogImplV(bool logToPrintf, bool logToASL, int aslLvl, const char* lvlStr, const char* format, va_list args) __printflike(5, 0); static inline void MVKLogImplV(bool logToPrintf, bool logToASL, int aslLvl, const char* lvlStr, const char* format, va_list args) { // Combine the level and format string @@ -190,6 +191,7 @@ static inline void MVKLogImplV(bool logToPrintf, bool logToASL, int aslLvl, cons * Combine the specified log level and format string, then log * the specified args to one or both of ASL and printf. */ +static inline void MVKLogImpl(bool logToPrintf, bool logToASL, int aslLvl, const char* lvlStr, const char* format, ...) __printflike(5, 6); static inline void MVKLogImpl(bool logToPrintf, bool logToASL, int aslLvl, const char* lvlStr, const char* format, ...) { va_list args; va_start(args, format); diff --git a/MoltenVK/MoltenVK/Utility/MVKFoundation.h b/MoltenVK/MoltenVK/Utility/MVKFoundation.h index 779f7a44..9f1a4dfc 100644 --- a/MoltenVK/MoltenVK/Utility/MVKFoundation.h +++ b/MoltenVK/MoltenVK/Utility/MVKFoundation.h @@ -103,7 +103,7 @@ char* mvkResultName(VkResult vkResult, char* name); * * - Logs the error code and message to the console */ -VkResult mvkNotifyErrorWithText(VkResult vkErr, const char* errFmt, ...); +VkResult mvkNotifyErrorWithText(VkResult vkErr, const char* errFmt, ...) __printflike(2, 3); #pragma mark -