summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2014-11-16 17:46:12 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2014-11-16 22:17:36 +0100
commitcfa702b278c126ed3e5d0d34aa7ca018504edb96 (patch)
treea69483e05df239fc69169b93ca6090d5fbfd68aa /src
parentc69654ce136fa6e7c097f9458ea999e66d6340bc (diff)
Feature test for GCC attributes
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/buffer.h2
-rw-r--r--src/config.h.in8
3 files changed, 13 insertions, 1 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c5814e0..c399713 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -99,6 +99,10 @@ CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
CHECK_C_SOURCE_COMPILES(
"int main() { __builtin_expect(0,0); return 0; }"
HAVE___BUILTIN_EXPECT)
+CHECK_C_SOURCE_COMPILES("
+ int f(void) __attribute__ (());
+ int main() { return 0; }
+" HAVE___ATTRIBUTE__)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
diff --git a/src/buffer.h b/src/buffer.h
index d14b38e..acbead7 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -110,7 +110,7 @@ CMARK_EXPORT
int cmark_strbuf_puts(cmark_strbuf *buf, const char *string);
CMARK_EXPORT
int cmark_strbuf_printf(cmark_strbuf *buf, const char *format, ...)
- __attribute__((format (printf, 2, 3)));
+ CMARK_ATTRIBUTE((format (printf, 2, 3)));
CMARK_EXPORT
int cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap);
CMARK_EXPORT
diff --git a/src/config.h.in b/src/config.h.in
index bd39c4e..5294bc9 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -7,3 +7,11 @@
#endif
#cmakedefine HAVE___BUILTIN_EXPECT
+
+#cmakedefine HAVE___ATTRIBUTE__
+
+#ifdef HAVE___ATTRIBUTE__
+ #define CMARK_ATTRIBUTE(list) __attribute__ (list)
+#else
+ #define CMARK_ATTRIBUTE(list)
+#endif