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

Unified Diff: runtime/platform/globals.h

Issue 10869063: Add attributions so printf like functions can have their arguments checked. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased Created 8 years, 3 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 | « runtime/platform/assert.h ('k') | runtime/platform/json.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/globals.h
diff --git a/runtime/platform/globals.h b/runtime/platform/globals.h
index cefd9dc6bcab8035a8c20bfadb4ea9bccd07f312..e75a45b9e3109d748edf655570509b8e324f2bb3 100644
--- a/runtime/platform/globals.h
+++ b/runtime/platform/globals.h
@@ -130,6 +130,15 @@
#endif // defined(TARGET_OS_WINDOWS)
+// Short form printf format specifiers
+#define Pd PRIdPTR
+#define Pu PRIuPTR
+#define Px PRIxPTR
+#define Pd64 PRId64
+#define Pu64 PRIu64
+#define Px64 PRIx64
+
+
// Suffixes for 64-bit integer literals.
#ifdef _MSC_VER
#define DART_INT64_C(x) x##I64
@@ -359,4 +368,21 @@ inline D bit_copy(const S& source) {
__result; })
#endif
+
+#if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS)
+//
+// Tell the compiler to do printf format string checking if the
+// compiler supports it; see the 'format' attribute in
+// <http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html>.
+//
+// N.B.: As the GCC manual states, "[s]ince non-static C++ methods
+// have an implicit 'this' argument, the arguments of such methods
+// should be counted from two, not one."
+//
+#define PRINTF_ATTRIBUTE(string_index, first_to_check) \
+ __attribute__((__format__(__printf__, string_index, first_to_check)))
+#else
+#define PRINTF_ATTRIBUTE(string_index, first_to_check)
+#endif
+
#endif // PLATFORM_GLOBALS_H_
« no previous file with comments | « runtime/platform/assert.h ('k') | runtime/platform/json.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698