Преглед на файлове

Merge branch 'feature/#64-add-gcc-printf-hints' of shimatta/shellmatta into develop

fix #64
shimatta преди 9 месеца
родител
ревизия
56b7a22405
променени са 1 файла, в които са добавени 17 реда и са изтрити 1 реда
  1. 17 1
      api/shellmatta.h

+ 17 - 1
api/shellmatta.h

@@ -25,6 +25,21 @@
 
 /* global defines */
 
+
+/*
+ * Define the printf format specifier for all GCC versions > 3.3
+ * This will let the compiler know that shelmatta_printf() is a function taking printf-like format specifiers.
+ */
+#ifndef SHELLMATTA_ATTR_FORMAT
+#   if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
+#       define SHELLMATTA_ATTR_FORMAT(fmt, args) __attribute__((__format__(__printf__, fmt, args)))
+#   else
+#       define SHELLMATTA_ATTR_FORMAT(fmt, args)
+#   endif
+#else
+#   define SHELLMATTA_ATTR_FORMAT(fmt, args)
+#endif
+
 /**
  * @brief definition of a shellmatta handle
  */
@@ -207,7 +222,8 @@ shellmatta_retCode_t shellmatta_opt_long(   shellmatta_handle_t         handle,
 #ifndef SHELLMATTA_STRIP_PRINTF
 shellmatta_retCode_t shellmatta_printf(     shellmatta_handle_t handle,
                                             const char          *fmt,
-                                            ...);
+                                            ...)
+                                            SHELLMATTA_ATTR_FORMAT(2, 3);
 #endif
 
 #endif