summaryrefslogtreecommitdiff
path: root/src/localconsts.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/localconsts.h')
-rw-r--r--src/localconsts.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/localconsts.h b/src/localconsts.h
index a120ed9d7..6e2122bcf 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -171,6 +171,40 @@
#define gnu_printf printf
#endif // __clang__
+/*
+ * A_FORMAT_PRINTF: Proxy for printf-like attribute tagging,
+ * All argument positions start indexed by 1
+ *
+ * isMember true if member function. The below will shift by one
+ * if required by toolchain.
+ * fmtIndex: position of format string in argument list
+ * firstArgIndex: position of first optional argument to format.
+ */
+#ifdef BAD_CILKPLUS
+#define A_FORMAT_MEMBER_SHIFT 0
+#else
+#define A_FORMAT_MEMBER_SHIFT 1
+#endif
+
+// idk how to clean this up
+#ifdef __GNUC__
+ #ifdef __OpenBSD__
+ #define A_FORMAT_PRINTF_FUNC printf
+ #else
+ #define A_FORMAT_PRINTF_FUNC gnu_printf
+ #endif
+#else
+ #define A_FORMAT_PRINTF_FUNC gnu_printf
+#endif
+
+#define A_FORMAT_PRINTF(isMember, fmtIndex, firstArgIndex) \
+ __attribute__((__format__( \
+ A_FORMAT_PRINTF_FUNC, \
+ ((fmtIndex) + ((isMember) ? A_FORMAT_MEMBER_SHIFT : 0)), \
+ ((firstArgIndex) + ((isMember) ? A_FORMAT_MEMBER_SHIFT : 0)) \
+ )))
+
+
#ifdef ADVGCC
#define const2 const