OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This file contains macros and macro-like constructs (e.g., templates) that | 5 // This file contains macros and macro-like constructs (e.g., templates) that |
6 // are commonly used throughout Chromium source. (It may also contain things | 6 // are commonly used throughout Chromium source. (It may also contain things |
7 // that are closely related to things that are commonly used that belong in this | 7 // that are closely related to things that are commonly used that belong in this |
8 // file.) | 8 // file.) |
9 | 9 |
10 #ifndef BASE_MACROS_H_ | 10 #ifndef BASE_MACROS_H_ |
(...skipping 17 matching lines...) Expand all Loading... |
28 #undef COMPILE_ASSERT | 28 #undef COMPILE_ASSERT |
29 | 29 |
30 #if __cplusplus >= 201103L | 30 #if __cplusplus >= 201103L |
31 | 31 |
32 // Under C++11, just use static_assert. | 32 // Under C++11, just use static_assert. |
33 #define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg) | 33 #define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg) |
34 | 34 |
35 #else | 35 #else |
36 | 36 |
37 template <bool> | 37 template <bool> |
38 struct CompileAssert { | 38 struct CompileAssert {}; |
39 }; | |
40 | 39 |
41 // Annotate a variable indicating it's ok if the variable is not used. | 40 // Annotate a variable indicating it's ok if the variable is not used. |
42 // (Typically used to silence a compiler warning when the assignment | 41 // (Typically used to silence a compiler warning when the assignment |
43 // is important for some other reason.) | 42 // is important for some other reason.) |
44 // Use like: | 43 // Use like: |
45 // int x ALLOW_UNUSED = ...; | 44 // int x ALLOW_UNUSED = ...; |
46 #if defined(COMPILER_GCC) | 45 #if defined(COMPILER_GCC) |
47 #define ALLOW_UNUSED __attribute__((unused)) | 46 #define ALLOW_UNUSED __attribute__((unused)) |
48 #else | 47 #else |
49 #define ALLOW_UNUSED | 48 #define ALLOW_UNUSED |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // - The array size is (bool(expr) ? 1 : -1), instead of simply | 88 // - The array size is (bool(expr) ? 1 : -1), instead of simply |
90 // | 89 // |
91 // ((expr) ? 1 : -1). | 90 // ((expr) ? 1 : -1). |
92 // | 91 // |
93 // This is to avoid running into a bug in MS VC 7.1, which | 92 // This is to avoid running into a bug in MS VC 7.1, which |
94 // causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1. | 93 // causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1. |
95 | 94 |
96 #endif | 95 #endif |
97 | 96 |
98 #endif // BASE_MACROS_H_ | 97 #endif // BASE_MACROS_H_ |
OLD | NEW |