aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--OpenAL32/Include/alMain.h8
-rw-r--r--config.h.in3
3 files changed, 13 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c60a11e..1577e054 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -136,6 +136,9 @@ ELSE()
ENDIF()
ENDIF()
+CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
+ int main() {return 0;}" HAVE_GCC_FORMAT)
+
CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 47f1adfa..48ea9a8a 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -28,6 +28,12 @@ typedef long long ALint64;
typedef unsigned long long ALuint64;
#endif
+#ifdef HAVE_GCC_FORMAT
+#define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y))))
+#else
+#define PRINTF_STYLE(x, y)
+#endif
+
#ifdef _WIN32
#ifndef _WIN32_WINNT
@@ -145,7 +151,7 @@ static inline void Sleep(ALuint t)
extern "C" {
#endif
-static __inline void al_print(const char *fname, unsigned int line, const char *fmt, ...)
+static __inline PRINTF_STYLE(3,4) void al_print(const char *fname, unsigned int line, const char *fmt, ...)
{
const char *fn;
char str[256];
diff --git a/config.h.in b/config.h.in
index 647cfe47..168b403a 100644
--- a/config.h.in
+++ b/config.h.in
@@ -67,6 +67,9 @@
/* Define if we have GCC's destructor attribute */
#cmakedefine HAVE_GCC_DESTRUCTOR
+/* Define if we have GCC's format attribute */
+#cmakedefine HAVE_GCC_FORMAT
+
/* Define if we have pthread_np.h */
#cmakedefine HAVE_PTHREAD_NP_H