]> git.sur5r.net Git - openocd/blobdiff - src/helper/command.h
corrective fix for MinGW GNU C99 printf compliance
[openocd] / src / helper / command.h
index e4908dd0e2ca4ff6d875be8cdb251d403238b02b..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);
@@ -98,6 +107,9 @@ extern void process_jim_events(void);
 #define                ERROR_COMMAND_CLOSE_CONNECTION          (-600)
 #define                ERROR_COMMAND_SYNTAX_ERROR                      (-601)
 #define                ERROR_COMMAND_NOTFOUND                          (-602)
+#define                ERROR_COMMAND_ARGUMENT_INVALID          (-603)
+#define                ERROR_COMMAND_ARGUMENT_OVERFLOW         (-604)
+#define                ERROR_COMMAND_ARGUMENT_UNDERFLOW        (-605)
 
 extern int fast_and_dangerous;
 
@@ -114,17 +126,17 @@ int parse_long(const char *str, long *ul);
 int parse_llong(const char *str, long long *ul);
 
 #define DECLARE_PARSE_WRAPPER(name, type) \
-       int parse_##name(const char *str, type *ul)
+       int parse##name(const char *str, type *ul)
 
-DECLARE_PARSE_WRAPPER(uint, unsigned);
-DECLARE_PARSE_WRAPPER(u32, uint32_t);
-DECLARE_PARSE_WRAPPER(u16, uint16_t);
-DECLARE_PARSE_WRAPPER(u8, uint8_t);
+DECLARE_PARSE_WRAPPER(_uint, unsigned);
+DECLARE_PARSE_WRAPPER(_u32, uint32_t);
+DECLARE_PARSE_WRAPPER(_u16, uint16_t);
+DECLARE_PARSE_WRAPPER(_u8, uint8_t);
 
-DECLARE_PARSE_WRAPPER(int, int);
-DECLARE_PARSE_WRAPPER(s32, int32_t);
-DECLARE_PARSE_WRAPPER(s16, int16_t);
-DECLARE_PARSE_WRAPPER(s8, int8_t);
+DECLARE_PARSE_WRAPPER(_int, int);
+DECLARE_PARSE_WRAPPER(_s32, int32_t);
+DECLARE_PARSE_WRAPPER(_s16, int16_t);
+DECLARE_PARSE_WRAPPER(_s8, int8_t);
 
 void script_debug(Jim_Interp *interp, const char *cmd, int argc, Jim_Obj *const *argv);