summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorsdefresne@chromium.org <sdefresne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-28 14:32:21 +0000
committersdefresne@chromium.org <sdefresne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-28 14:32:21 +0000
commitbb259180a51d04e2ec5a3437ae4a8c49eb700bd7 (patch)
tree623a2c7ea56a94ba5c4ca3f90f18dfcc5455e050 /base
parent3dab7b72278dcecce11e06eea61a140716b6aaaa (diff)
downloadchromium_src-bb259180a51d04e2ec5a3437ae4a8c49eb700bd7.zip
chromium_src-bb259180a51d04e2ec5a3437ae4a8c49eb700bd7.tar.gz
chromium_src-bb259180a51d04e2ec5a3437ae4a8c49eb700bd7.tar.bz2
Add a macro NSSTRING_FORMAT for Objective-C formatting function
Objective-C functions that accepts a format string parameter cannot use the PRINTF_FORMAT since this does not supports the %@ specifier. Define a new macro NSSTRING_FORMAT that tell the compiler the function formats using the same rules as +[NSString stringWithFormat:]. References: http://nshipster.com/__attribute__/ BUG=None Review URL: https://codereview.chromium.org/183443002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254099 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/compiler_specific.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
index cbb60a0d..c83b6b5 100644
--- a/base/compiler_specific.h
+++ b/base/compiler_specific.h
@@ -196,6 +196,18 @@
// If available, it would look like:
// __attribute__((format(wprintf, format_param, dots_param)))
+#if defined(__OBJC__)
+// Tell the compiler a function is using a +[NSString stringWithFormat:]
+// style format string. |format_param| is the one-based index of the format
+// string parameter; |dots_param| is the one-based index of the "..."
+// parameter. This should only be used when building Objective-C code.
+#if defined(COMPILER_GCC)
+#define NSSTRING_FORMAT(format_param, dots_param) \
+ __attribute__((format(__NSString__, format_param, dots_param)))
+#else
+#define NSSTRING_FORMAT(format_param, dots_param)
+#endif // defined(COMPILER_GCC)
+#endif // defined(__OBJC__)
// MemorySanitizer annotations.
#if defined(MEMORY_SANITIZER) && !defined(OS_NACL)