OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_COMPILER_SPECIFIC_H_ | 5 #ifndef BASE_COMPILER_SPECIFIC_H_ |
6 #define BASE_COMPILER_SPECIFIC_H_ | 6 #define BASE_COMPILER_SPECIFIC_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 #define OVERRIDE override | 104 #define OVERRIDE override |
105 #elif defined(__clang__) | 105 #elif defined(__clang__) |
106 #define OVERRIDE override | 106 #define OVERRIDE override |
107 #else | 107 #else |
108 #define OVERRIDE | 108 #define OVERRIDE |
109 #endif | 109 #endif |
110 | 110 |
111 // Annotate a function indicating the caller must examine the return value. | 111 // Annotate a function indicating the caller must examine the return value. |
112 // Use like: | 112 // Use like: |
113 // int foo() WARN_UNUSED_RESULT; | 113 // int foo() WARN_UNUSED_RESULT; |
114 // To explicitly ignore a result, see |ignore_result()| in basic_types.h. | |
Mark Mentovai
2011/05/19 23:17:13
Say <base/basictypes.h>, with no underscore.
| |
114 #if defined(COMPILER_GCC) | 115 #if defined(COMPILER_GCC) |
115 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 116 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
116 #else | 117 #else |
117 #define WARN_UNUSED_RESULT | 118 #define WARN_UNUSED_RESULT |
118 #endif | 119 #endif |
119 | 120 |
120 // Tell the compiler a function is using a printf-style format string. | 121 // Tell the compiler a function is using a printf-style format string. |
121 // |format_param| is the one-based index of the format string parameter; | 122 // |format_param| is the one-based index of the format string parameter; |
122 // |dots_param| is the one-based index of the "..." parameter. | 123 // |dots_param| is the one-based index of the "..." parameter. |
123 // For v*printf functions (which take a va_list), pass 0 for dots_param. | 124 // For v*printf functions (which take a va_list), pass 0 for dots_param. |
124 // (This is undocumented but matches what the system C headers do.) | 125 // (This is undocumented but matches what the system C headers do.) |
125 #if defined(COMPILER_GCC) | 126 #if defined(COMPILER_GCC) |
126 #define PRINTF_FORMAT(format_param, dots_param) \ | 127 #define PRINTF_FORMAT(format_param, dots_param) \ |
127 __attribute__((format(printf, format_param, dots_param))) | 128 __attribute__((format(printf, format_param, dots_param))) |
128 #else | 129 #else |
129 #define PRINTF_FORMAT(format_param, dots_param) | 130 #define PRINTF_FORMAT(format_param, dots_param) |
130 #endif | 131 #endif |
131 | 132 |
132 // WPRINTF_FORMAT is the same, but for wide format strings. | 133 // WPRINTF_FORMAT is the same, but for wide format strings. |
133 // This doesn't appear to yet be implemented in any compiler. | 134 // This doesn't appear to yet be implemented in any compiler. |
134 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . | 135 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . |
135 #define WPRINTF_FORMAT(format_param, dots_param) | 136 #define WPRINTF_FORMAT(format_param, dots_param) |
136 // If available, it would look like: | 137 // If available, it would look like: |
137 // __attribute__((format(wprintf, format_param, dots_param))) | 138 // __attribute__((format(wprintf, format_param, dots_param))) |
138 | 139 |
139 #endif // BASE_COMPILER_SPECIFIC_H_ | 140 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |