| 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 10 matching lines...) Expand all Loading... |
| 21 // http://msdn.microsoft.com/en-us/library/d9x1s805.aspx | 21 // http://msdn.microsoft.com/en-us/library/d9x1s805.aspx |
| 22 | 22 |
| 23 // MSVC_SUPPRESS_WARNING disables warning |n| for the remainder of the line and | 23 // MSVC_SUPPRESS_WARNING disables warning |n| for the remainder of the line and |
| 24 // for the next line of the source file. | 24 // for the next line of the source file. |
| 25 #define MSVC_SUPPRESS_WARNING(n) __pragma(warning(suppress:n)) | 25 #define MSVC_SUPPRESS_WARNING(n) __pragma(warning(suppress:n)) |
| 26 | 26 |
| 27 // MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. | 27 // MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. |
| 28 // The warning remains disabled until popped by MSVC_POP_WARNING. | 28 // The warning remains disabled until popped by MSVC_POP_WARNING. |
| 29 #define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ | 29 #define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ |
| 30 __pragma(warning(disable:n)) | 30 __pragma(warning(disable:n)) |
| 31 |
| 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 |
| 34 // warnings. |
| 35 #define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) |
| 36 |
| 37 // Pop effects of innermost MSVC_PUSH_* macro. |
| 31 #define MSVC_POP_WARNING() __pragma(warning(pop)) | 38 #define MSVC_POP_WARNING() __pragma(warning(pop)) |
| 32 | 39 |
| 33 // Allows |this| to be passed as an argument in constructor initializer lists. | 40 // Allows |this| to be passed as an argument in constructor initializer lists. |
| 34 // This uses push/pop instead of the seemingly simpler suppress feature to avoid | 41 // This uses push/pop instead of the seemingly simpler suppress feature to avoid |
| 35 // having the warning be disabled for more than just |code|. | 42 // having the warning be disabled for more than just |code|. |
| 36 // | 43 // |
| 37 // Example usage: | 44 // Example usage: |
| 38 // Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} | 45 // Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} |
| 39 // | 46 // |
| 40 // Compiler warning C4355: 'this': used in base member initializer list: | 47 // Compiler warning C4355: 'this': used in base member initializer list: |
| 41 // http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx | 48 // http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx |
| 42 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ | 49 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ |
| 43 code \ | 50 code \ |
| 44 MSVC_POP_WARNING() | 51 MSVC_POP_WARNING() |
| 45 | 52 |
| 46 #else // COMPILER_MSVC | 53 #else // COMPILER_MSVC |
| 47 | 54 |
| 48 #define MSVC_SUPPRESS_WARNING(n) | 55 #define MSVC_SUPPRESS_WARNING(n) |
| 49 #define MSVC_PUSH_DISABLE_WARNING(n) | 56 #define MSVC_PUSH_DISABLE_WARNING(n) |
| 57 #define MSVC_PUSH_WARNING_LEVEL(n) |
| 50 #define MSVC_POP_WARNING() | 58 #define MSVC_POP_WARNING() |
| 51 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) code | 59 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) code |
| 52 | 60 |
| 53 #endif // COMPILER_MSVC | 61 #endif // COMPILER_MSVC |
| 54 | 62 |
| 55 #endif // BASE_COMPILER_SPECIFIC_H_ | 63 #endif // BASE_COMPILER_SPECIFIC_H_ |
| 56 | 64 |
| OLD | NEW |