From c47424d39b9b2f782adc1abf2e2e9090fc2ec4e6 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Thu, 20 Oct 2022 12:07:38 +0200 Subject: Introduce a macro to implement `printf` attribute This lets us remove a lot of `#ifdef __GNUC__` in function declarations, which makes them more readable. --- binaryninjaapi.h | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 0488803e..a6a98da2 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -516,9 +516,7 @@ namespace BinaryNinja { \param fmt C-style format string. \param ... Variable arguments corresponding to the format string. */ -#ifdef __GNUC__ - __attribute__((format(printf, 2, 3))) -#endif + BN_PRINTF_ATTRIBUTE(2, 3) void Log(BNLogLevel level, const char* fmt, ...); /*! LogTrace only writes text to the error console if the console is set to log level: DebugLog @@ -529,9 +527,7 @@ namespace BinaryNinja { \param fmt C-style format string. \param ... Variable arguments corresponding to the format string. */ -#ifdef __GNUC__ - __attribute__((format(printf, 1, 2))) -#endif + BN_PRINTF_ATTRIBUTE(1, 2) void LogTrace(const char* fmt, ...); @@ -543,9 +539,7 @@ namespace BinaryNinja { \param fmt C-style format string. \param ... Variable arguments corresponding to the format string. */ -#ifdef __GNUC__ - __attribute__((format(printf, 1, 2))) -#endif + BN_PRINTF_ATTRIBUTE(1, 2) void LogDebug(const char* fmt, ...); /*! LogInfo always writes text to the error console, and corresponds to the log level: InfoLog. @@ -556,9 +550,7 @@ namespace BinaryNinja { \param fmt C-style format string. \param ... Variable arguments corresponding to the format string. */ -#ifdef __GNUC__ - __attribute__((format(printf, 1, 2))) -#endif + BN_PRINTF_ATTRIBUTE(1, 2) void LogInfo(const char* fmt, ...); /*! LogWarn writes text to the error console including a warning icon, @@ -569,9 +561,7 @@ namespace BinaryNinja { \param fmt C-style format string. \param ... Variable arguments corresponding to the format string. */ -#ifdef __GNUC__ - __attribute__((format(printf, 1, 2))) -#endif + BN_PRINTF_ATTRIBUTE(1, 2) void LogWarn(const char* fmt, ...); /*! LogError writes text to the error console and pops up the error console. Additionall, @@ -582,9 +572,7 @@ namespace BinaryNinja { \param fmt C-style format string. \param ... Variable arguments corresponding to the format string. */ -#ifdef __GNUC__ - __attribute__((format(printf, 1, 2))) -#endif + BN_PRINTF_ATTRIBUTE(1, 2) void LogError(const char* fmt, ...); /*! LogAlert pops up a message box displaying the alert message and logs to the error console. @@ -595,9 +583,7 @@ namespace BinaryNinja { \param fmt C-style format string. \param ... Variable arguments corresponding to the format string. */ -#ifdef __GNUC__ - __attribute__((format(printf, 1, 2))) -#endif + BN_PRINTF_ATTRIBUTE(1, 2) void LogAlert(const char* fmt, ...); /*! Redirects the minimum level passed to standard out -- cgit v1.3.1