]> git.sur5r.net Git - openocd/blobdiff - src/helper/command.h
corrective fix for MinGW GNU C99 printf compliance
[openocd] / src / helper / command.h
index 3e7bea9221c3133c9da31246340eca5e67b00921..ba825bcb48485a9e61d22efc0cd943b6908ffb57 100644 (file)
@@ -2,7 +2,7 @@
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
- *   Copyright (C) 2007,2008 Øyvind Harboe                                 *
+ *   Copyright (C) 2007,2008 Øyvind Harboe                                 *
  *   oyvind.harboe@zylin.com                                               *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 #include "jim.h"
 #endif
 
+/* To achieve C99 printf compatibility in MinGW, gnu_printf should be
+ * used for __attribute__((format( ... ))), with GCC v4.4 or later
+ */
+#if (defined(IS_MINGW) && (((__GNUC__ << 16) + __GNUC_MINOR__) >= 0x00040004))
+#define PRINTF_ATTRIBUTE_FORMAT gnu_printf
+#else
+#define PRINTF_ATTRIBUTE_FORMAT printf
+#endif
+
 enum command_mode
 {
        COMMAND_EXEC,
@@ -85,12 +94,12 @@ extern command_context_t* command_init(void);
 extern int command_done(command_context_t *context);
 
 extern void command_print(command_context_t *context, const char *format, ...)
-               __attribute__ ((format (printf, 2, 3)));
+               __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
 extern void command_print_sameline(command_context_t *context, const char *format, ...)
-               __attribute__ ((format (printf, 2, 3)));
+               __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
 extern int command_run_line(command_context_t *context, char *line);
 extern int command_run_linef(command_context_t *context, const char *format, ...)
-               __attribute__ ((format (printf, 2, 3)));
+               __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
 extern void command_output_text(command_context_t *context, const char *data);
 
 extern void process_jim_events(void);