summaryrefslogtreecommitdiff
path: root/compiler.h
diff options
context:
space:
mode:
authorZbigniew Chyla <zbigniew@chyla.pl>2015-01-16 15:46:59 +0100
committerEric S. Raymond <esr@thyrsus.com>2015-01-21 10:47:42 -0500
commit9b07a07f6fed92d1b041bfcd8a49ca7314f75ac3 (patch)
tree4eb913a03a7b9261f5f4c9d156466fd7eec5ce58 /compiler.h
parentfca5b90829621e119a310225b4f1358cd6914d5c (diff)
downloadgpsd-9b07a07f6fed92d1b041bfcd8a49ca7314f75ac3.tar.gz
Add compiler.h with compiler specific macros.
Use new macros (UNUSED, PRINTF_FUNC) where appropriate. This change doesn't affect generated binary code.
Diffstat (limited to 'compiler.h')
-rw-r--r--compiler.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/compiler.h b/compiler.h
new file mode 100644
index 00000000..9d6f3629
--- /dev/null
+++ b/compiler.h
@@ -0,0 +1,25 @@
+/*
+ * compiler.h - compiler specific macros
+ *
+ * This software is distributed under a BSD-style license. See the
+ * file "COPYING" in the toop-level directory of the distribution for details.
+ */
+#ifndef _GPSD_COMPILER_H_
+#define _GPSD_COMPILER_H_
+
+/* Macro for declaring function with printf-like arguments. */
+# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+#define PRINTF_FUNC(format_index, arg_index) \
+ __attribute__((__format__(__printf__, format_index, arg_index)))
+# else
+#define PRINTF_FUNC(format_index, arg_indx)
+#endif
+
+/* Macro for declaring function arguments unused. */
+#if defined(__GNUC__)
+#define UNUSED __attribute__((unused))
+#else
+#define UNUSED
+#endif
+
+#endif /* _GPSD_COMPILER_H_ */