OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project 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 V8_BASE_COMPILER_SPECIFIC_H_ | 5 #ifndef V8_BASE_COMPILER_SPECIFIC_H_ |
6 #define V8_BASE_COMPILER_SPECIFIC_H_ | 6 #define V8_BASE_COMPILER_SPECIFIC_H_ |
7 | 7 |
8 #include "include/v8config.h" | 8 #include "include/v8config.h" |
9 | 9 |
10 // Annotate a typedef or function indicating it's ok if it's not used. | 10 // Annotate a typedef or function indicating it's ok if it's not used. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 // Annotate a function indicating the caller must examine the return value. | 45 // Annotate a function indicating the caller must examine the return value. |
46 // Use like: | 46 // Use like: |
47 // int foo() WARN_UNUSED_RESULT; | 47 // int foo() WARN_UNUSED_RESULT; |
48 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT | 48 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT |
49 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 49 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
50 #else | 50 #else |
51 #define WARN_UNUSED_RESULT /* NOT SUPPORTED */ | 51 #define WARN_UNUSED_RESULT /* NOT SUPPORTED */ |
52 #endif | 52 #endif |
53 | 53 |
| 54 |
| 55 // The C++ standard requires that static const members have an out-of-class |
| 56 // definition (in a single compilation unit), but MSVC chokes on this (when |
| 57 // language extensions, which are required, are enabled). (You're only likely to |
| 58 // notice the need for a definition if you take the address of the member or, |
| 59 // more commonly, pass it to a function that takes it as a reference argument -- |
| 60 // probably an STL function.) This macro makes MSVC do the right thing. See |
| 61 // http://msdn.microsoft.com/en-us/library/34h23df8(v=vs.100).aspx for more |
| 62 // information. Use like: |
| 63 // |
| 64 // In .h file: |
| 65 // struct Foo { |
| 66 // static const int kBar = 5; |
| 67 // }; |
| 68 // |
| 69 // In .cc file: |
| 70 // STATIC_CONST_MEMBER_DEFINITION const int Foo::kBar; |
| 71 #if V8_HAS_DECLSPEC_SELECTANY |
| 72 #define STATIC_CONST_MEMBER_DEFINITION __declspec(selectany) |
| 73 #else |
| 74 #define STATIC_CONST_MEMBER_DEFINITION |
| 75 #endif |
| 76 |
54 #endif // V8_BASE_COMPILER_SPECIFIC_H_ | 77 #endif // V8_BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |