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

Unified Diff: base/format_macros.h

Issue 187793003: Define print format macros for NSInteger & NSUInteger (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and try CQ again Created 6 years, 9 months 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
« no previous file with comments | « no previous file | base/mac/foundation_util_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/format_macros.h
diff --git a/base/format_macros.h b/base/format_macros.h
index 466d79be731bf5d8c2e4f57c5c1109d5d985b612..4d90c593a61690895f152a4b03e597b1c3fc3613 100644
--- a/base/format_macros.h
+++ b/base/format_macros.h
@@ -46,6 +46,34 @@
#define PRIuS "zu"
#endif
+// The size of NSInteger and NSUInteger varies between 32-bit and 64-bit
+// architectures and Apple does not provides standard format macros and
+// recommends casting. This has many drawbacks, so instead define macros
+// for formatting those types.
+#if defined(OS_MACOSX)
+#if defined(ARCH_CPU_64_BITS)
+#if !defined(PRIdNS)
+#define PRIdNS "ld"
+#endif
+#if !defined(PRIuNS)
+#define PRIuNS "lu"
+#endif
+#if !defined(PRIxNS)
+#define PRIxNS "lx"
+#endif
+#else // defined(ARCH_CPU_64_BITS)
+#if !defined(PRIdNS)
+#define PRIdNS "d"
+#endif
+#if !defined(PRIuNS)
+#define PRIuNS "u"
+#endif
+#if !defined(PRIxNS)
+#define PRIxNS "x"
+#endif
+#endif
+#endif // defined(OS_MACOSX)
+
#else // OS_WIN
#if !defined(PRId64)
« no previous file with comments | « no previous file | base/mac/foundation_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698