diff options
| -rw-r--r-- | source/core/slang-common.h | 6 | ||||
| -rw-r--r-- | source/core/slang-secure-crt.h | 4 | ||||
| -rw-r--r-- | source/core/slang-writer.h | 1 |
3 files changed, 11 insertions, 0 deletions
diff --git a/source/core/slang-common.h b/source/core/slang-common.h index 7fddb067e..cd1490a20 100644 --- a/source/core/slang-common.h +++ b/source/core/slang-common.h @@ -120,6 +120,12 @@ template<typename T> void slang_use_obj(T&) {} #endif #endif +#if defined(_MSC_VER) +# define SLANG_ATTR_PRINTF(string_index, varargs_index) +#else +# define SLANG_ATTR_PRINTF(string_index, varargs_index) __attribute__((format(printf, string_index, varargs_index))) +#endif + #ifndef SLANG_RT_API #define SLANG_RT_API #endif diff --git a/source/core/slang-secure-crt.h b/source/core/slang-secure-crt.h index 991fe939e..b6f6671dd 100644 --- a/source/core/slang-secure-crt.h +++ b/source/core/slang-secure-crt.h @@ -47,6 +47,7 @@ inline size_t strnlen_s(const char * str, size_t numberOfElements) #endif } +__attribute__((format(printf, 3, 4))) inline int sprintf_s(char * buffer, size_t sizeOfBuffer, const char * format, ...) { va_list argptr; @@ -56,6 +57,9 @@ inline int sprintf_s(char * buffer, size_t sizeOfBuffer, const char * format, .. return rs; } +// A patch was submitted to GCC wchar_t support in 2001, so I'm sure we can +// enable this any day now... +// __attribute__((format(wprintf, 3, 4))) inline int swprintf_s(wchar_t * buffer, size_t sizeOfBuffer, const wchar_t * format, ...) { va_list argptr; diff --git a/source/core/slang-writer.h b/source/core/slang-writer.h index ccdcb3747..2a86af629 100644 --- a/source/core/slang-writer.h +++ b/source/core/slang-writer.h @@ -16,6 +16,7 @@ namespace Slang class WriterHelper { public: + SLANG_ATTR_PRINTF(2, 3) SlangResult print(const char* format, ...); SlangResult put(const char* text); SlangResult put(const UnownedStringSlice& text); |
