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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 // | 47 // |
48 // Example usage: | 48 // Example usage: |
49 // Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} | 49 // Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} |
50 // | 50 // |
51 // Compiler warning C4355: 'this': used in base member initializer list: | 51 // Compiler warning C4355: 'this': used in base member initializer list: |
52 // http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx | 52 // http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx |
53 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ | 53 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ |
54 code \ | 54 code \ |
55 MSVC_POP_WARNING() | 55 MSVC_POP_WARNING() |
56 | 56 |
57 // Allows exporting a class that inherits from a non-exported base class. | |
58 // This uses suppress instead of push/pop because the delimiter after the | |
59 // declaration (either "," or "{") has to be placed before the pop macro. | |
60 // | |
61 // Example usage: | |
62 // Class EXPORT_API Foo : NON_EXPORTED_BASE(public Bar) { | |
brettw
2011/05/18 06:06:18
Did you mean "Class" to be lower-case?
rvargas (doing something else)
2011/05/18 18:13:48
Yes, fixed.
| |
63 // | |
64 // MSVC Compiler warning C4275: | |
65 // non dll-interface class 'Bar' used as base for dll-interface class 'Foo' | |
66 // http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx | |
brettw
2011/05/18 06:06:18
Your URL doesn't seem to talk about C4275. I searc
rvargas (doing something else)
2011/05/18 18:13:48
I added this to the comment:
// Note that this is
| |
67 #define NON_EXPORTED_BASE(code) MSVC_SUPPRESS_WARNING(4275) \ | |
68 code | |
69 | |
57 #else // Not MSVC | 70 #else // Not MSVC |
58 | 71 |
59 #define MSVC_SUPPRESS_WARNING(n) | 72 #define MSVC_SUPPRESS_WARNING(n) |
60 #define MSVC_PUSH_DISABLE_WARNING(n) | 73 #define MSVC_PUSH_DISABLE_WARNING(n) |
61 #define MSVC_PUSH_WARNING_LEVEL(n) | 74 #define MSVC_PUSH_WARNING_LEVEL(n) |
62 #define MSVC_POP_WARNING() | 75 #define MSVC_POP_WARNING() |
63 #define MSVC_DISABLE_OPTIMIZE() | 76 #define MSVC_DISABLE_OPTIMIZE() |
64 #define MSVC_ENABLE_OPTIMIZE() | 77 #define MSVC_ENABLE_OPTIMIZE() |
65 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) code | 78 #define ALLOW_THIS_IN_INITIALIZER_LIST(code) code |
79 #define NON_EXPORTED_BASE(code) code | |
66 | 80 |
67 #endif // COMPILER_MSVC | 81 #endif // COMPILER_MSVC |
68 | 82 |
69 | 83 |
70 // Annotate a variable indicating it's ok if the variable is not used. | 84 // Annotate a variable indicating it's ok if the variable is not used. |
71 // (Typically used to silence a compiler warning when the assignment | 85 // (Typically used to silence a compiler warning when the assignment |
72 // is important for some other reason.) | 86 // is important for some other reason.) |
73 // Use like: | 87 // Use like: |
74 // int x ALLOW_UNUSED = ...; | 88 // int x ALLOW_UNUSED = ...; |
75 #if defined(COMPILER_GCC) | 89 #if defined(COMPILER_GCC) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 #endif | 128 #endif |
115 | 129 |
116 // WPRINTF_FORMAT is the same, but for wide format strings. | 130 // WPRINTF_FORMAT is the same, but for wide format strings. |
117 // This doesn't appear to yet be implemented in any compiler. | 131 // This doesn't appear to yet be implemented in any compiler. |
118 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . | 132 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . |
119 #define WPRINTF_FORMAT(format_param, dots_param) | 133 #define WPRINTF_FORMAT(format_param, dots_param) |
120 // If available, it would look like: | 134 // If available, it would look like: |
121 // __attribute__((format(wprintf, format_param, dots_param))) | 135 // __attribute__((format(wprintf, format_param, dots_param))) |
122 | 136 |
123 #endif // BASE_COMPILER_SPECIFIC_H_ | 137 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |