changeset 3574:e7d314faaf73 draft

Extend printf warnings to error()
author Wladimir J. van der Laan <laanwj@gmail.com>
date Sun, 30 Sep 2012 14:34:05 +0200
parents 2b2caafbbf33
children f014b15a478b
files src/util.h
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/util.h
+++ b/src/util.h
@@ -56,13 +56,22 @@
 
 /* Format characters for (s)size_t and ptrdiff_t */
 #if defined(_MSC_VER) || defined(__MSVCRT__)
+  /* (s)size_t and ptrdiff_t have the same size specifier in MSVC:
+     http://msdn.microsoft.com/en-us/library/tcxf1dw6%28v=vs.100%29.aspx
+   */
   #define PRIszx    "Ix"
   #define PRIszu    "Iu"
   #define PRIszd    "Id"
-#else
+  #define PRIpdx    "Ix"
+  #define PRIpdu    "Iu"
+  #define PRIpdd    "Id"
+#else /* C99 standard */
   #define PRIszx    "zx"
   #define PRIszu    "zu"
   #define PRIszd    "zd"
+  #define PRIpdx    "tx"
+  #define PRIpdu    "tu"
+  #define PRIpdd    "td"
 #endif
 
 // This is needed because the foreach macro can't get over the comma in pair<t1, t2>
@@ -154,6 +163,8 @@
 #define strprintf(format, ...) real_strprintf(format, 0, __VA_ARGS__)
 std::string vstrprintf(const char *format, va_list ap);
 
+bool ATTR_WARN_PRINTF(1,2) error(const char *format, ...);
+
 /* Redefine printf so that it directs output to debug.log
  *
  * Do this *after* defining the other printf-like functions, because otherwise the
@@ -162,7 +173,6 @@
  */
 #define printf OutputDebugStringF
 
-bool error(const char *format, ...);
 void LogException(std::exception* pex, const char* pszThread);
 void PrintException(std::exception* pex, const char* pszThread);
 void PrintExceptionContinue(std::exception* pex, const char* pszThread);