OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(COMPILER_MSVC) | 10 #if defined(COMPILER_MSVC) |
(...skipping 19 matching lines...) Expand all Loading... |
30 __pragma(warning(disable:n)) | 30 __pragma(warning(disable:n)) |
31 | 31 |
32 // MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level | 32 // MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level |
33 // remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all | 33 // remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all |
34 // warnings. | 34 // warnings. |
35 #define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) | 35 #define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) |
36 | 36 |
37 // Pop effects of innermost MSVC_PUSH_* macro. | 37 // Pop effects of innermost MSVC_PUSH_* macro. |
38 #define MSVC_POP_WARNING() __pragma(warning(pop)) | 38 #define MSVC_POP_WARNING() __pragma(warning(pop)) |
39 | 39 |
| 40 #define MSVC_DISABLE_OPTIMIZE() __pragma(optimize("", off)) |
| 41 #define MSVC_ENABLE_OPTIMIZE() __pragma(optimize("", on)) |
| 42 |
40 // Allows |this| to be passed as an argument in constructor initializer lists. | 43 // Allows |this| to be passed as an argument in constructor initializer lists. |
41 // This uses push/pop instead of the seemingly simpler suppress feature to avoid | 44 // This uses push/pop instead of the seemingly simpler suppress feature to avoid |
42 // having the warning be disabled for more than just |code|. | 45 // having the warning be disabled for more than just |code|. |
43 // | 46 // |
44 // Example usage: | 47 // Example usage: |
45 // Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} | 48 // Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} |
46 // | 49 // |
47 // Compiler warning C4355: 'this': used in base member initializer list: | 50 // Compiler warning C4355: 'this': used in base member initializer list: |
48 // http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx | 51 // http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx |
49 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ | 52 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ |
50 code \ | 53 code \ |
51 MSVC_POP_WARNING() | 54 MSVC_POP_WARNING() |
52 | 55 |
53 #else // COMPILER_MSVC | 56 #else // COMPILER_MSVC |
54 | 57 |
55 #define MSVC_SUPPRESS_WARNING(n) | 58 #define MSVC_SUPPRESS_WARNING(n) |
56 #define MSVC_PUSH_DISABLE_WARNING(n) | 59 #define MSVC_PUSH_DISABLE_WARNING(n) |
57 #define MSVC_PUSH_WARNING_LEVEL(n) | 60 #define MSVC_PUSH_WARNING_LEVEL(n) |
58 #define MSVC_POP_WARNING() | 61 #define MSVC_POP_WARNING() |
| 62 #define MSVC_DISABLE_OPTIMIZE() |
| 63 #define MSVC_ENABLE_OPTIMIZE() |
59 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) code | 64 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) code |
60 | 65 |
61 #endif // COMPILER_MSVC | 66 #endif // COMPILER_MSVC |
62 | 67 |
63 #endif // BASE_COMPILER_SPECIFIC_H_ | 68 #endif // BASE_COMPILER_SPECIFIC_H_ |
64 | 69 |
OLD | NEW |