Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1345)

Unified Diff: base/format_macros.h

Issue 339059: Add compiler-specific "examine printf format" attributes to printfs. (Closed)
Patch Set: cleanups Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/format_macros.h
diff --git a/base/format_macros.h b/base/format_macros.h
index 383579f3a43107863cb40642106a17dcaaa9e7c8..d218f48a840178770ed1541b4a058c25a9cf0c10 100644
--- a/base/format_macros.h
+++ b/base/format_macros.h
@@ -5,14 +5,21 @@
#ifndef BASE_FORMAT_MACROS_H_
#define BASE_FORMAT_MACROS_H_
-// This file defines the C99 format macros for 64-bit values. If you wish to
-// print a 64-bit value in a portable way do:
+// This file defines the format macros for some integer types.
+
+// To print a 64-bit value in a portable way:
// int64_t value;
// printf("xyz:%" PRId64, value);
+// The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
//
// For wide strings, prepend "Wide" to the macro:
// int64_t value;
// StringPrintf(L"xyz: %" WidePRId64, value);
+//
+// To print a size_t value in a portable way:
+// size_t size;
+// printf("xyz: %" PRIuS, size);
+// The "u" in the macro corresponds to %u, and S is for "size".
#include "build/build_config.h"
@@ -35,6 +42,8 @@
#define WidePRIu64 PRIu64
#define WidePRIx64 PRIx64
+#define PRIuS "zu"
+
#else // OS_WIN
#if !defined(PRId64)
@@ -53,6 +62,8 @@
#define WidePRIu64 L"I64u"
#define WidePRIx64 L"I64x"
+#define PRIuS "Iu"
+
#endif
#endif // !BASE_FORMAT_MACROS_H_
« no previous file with comments | « base/compiler_specific.h ('k') | base/histogram.cc » ('j') | base/string_util_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698