summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2016-03-27 19:19:35 +0200
committerDavid Tardon <dtardon@redhat.com>2016-03-27 19:19:38 +0200
commitfaf590599ddcc73b433f46b22c8ae36ff95a1782 (patch)
treeb1cbda8c4e9f8ed5a18080fe65752879d1bc83ba
parent34d8b1ce7188e22ce73d589ef360aa72913a9b09 (diff)
check for __attribute__((__format__())) in configure
-rw-r--r--configure.ac9
-rw-r--r--src/lib/libsw602_utils.h6
2 files changed, 14 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 65d5fdb..dfa4153 100644
--- a/configure.ac
+++ b/configure.ac
@@ -221,6 +221,15 @@ AS_IF([test "x$enable_debug" = "xyes"], [
DEBUG_CXXFLAGS="-DDEBUG -g"
CXXFLAGS="$CXXFLAGS -O0"
CFLAGS="$CFLAGS -O0"
+ AC_MSG_CHECKING([if the compiler supports __attribute__((__format__()))])
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+ void print(const char *, ...) __attribute__((__format__(__printf__, 1, 2)));
+ ])], [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_ATTRIBUTE_FORMAT], [1], [Define to 1 if your compiler supports __attribute__((__format__()))])
+ ], [
+ AC_MSG_RESULT([no])
+ ])
], [
DEBUG_CXXFLAGS="-DNDEBUG"
])
diff --git a/src/lib/libsw602_utils.h b/src/lib/libsw602_utils.h
index e49c4c6..380f08b 100644
--- a/src/lib/libsw602_utils.h
+++ b/src/lib/libsw602_utils.h
@@ -10,6 +10,10 @@
#ifndef INCLUDED_LIBSW602_UTILS_H
#define INCLUDED_LIBSW602_UTILS_H
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <boost/cstdint.hpp>
#include <librevenge-stream/librevenge-stream.h>
@@ -21,7 +25,7 @@ namespace libsw602
// do nothing with debug messages in a release compile
#ifdef DEBUG
-#if defined(__clang__) || defined(__GNUC__)
+#if defined(HAVE_ATTRIBUTE_FORMAT)
# define SW602_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((__format__(__printf__, fmt, arg)))
#else
# define SW602_ATTRIBUTE_PRINTF(fmt, arg)