Define |OPENSSL_PRINTF_FORMAT_FUNC| for format string annotations. This centralizes the conditional logic into openssl/base.h so that it doesn't have to be repeated. The name |OPENSSL_PRINTF_FORMAT_FUNC| was chosen in anticipation of eventually defining an |OPENSSL_PRINTF_FORMAT_ARG| for MSVC-style parameter annotations. Change-Id: I273e6eddd209e696dc9f82099008c35b6d477cdb Reviewed-on: https://boringssl-review.googlesource.com/6909 Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/include/openssl/base.h b/include/openssl/base.h index 47b3ccb..65ab3f7 100644 --- a/include/openssl/base.h +++ b/include/openssl/base.h
@@ -138,6 +138,15 @@ #endif /* defined(BORINGSSL_SHARED_LIBRARY) */ + +#if defined(__GNUC__) +#define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) \ + __attribute__((format(printf, string_index, first_to_check))) +#else +#define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) +#endif + + /* CRYPTO_THREADID is a dummy value. */ typedef int CRYPTO_THREADID;