cmark

My personal build of CMark ✏️

Commit
cfa702b278c126ed3e5d0d34aa7ca018504edb96
Parent
c69654ce136fa6e7c097f9458ea999e66d6340bc
Author
Nick Wellnhofer <wellnhofer@aevum.de>
Date

Feature test for GCC attributes

Diffstat

3 files changed, 13 insertions, 1 deletion

Status File Name N° Changes Insertions Deletions
Modified src/CMakeLists.txt 4 4 0
Modified src/buffer.h 2 1 1
Modified src/config.h.in 8 8 0
diff --git 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
@@ -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
@@ -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