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 #ifndef MOJO_PUBLIC_C_SYSTEM_MACROS_H_ | 5 #ifndef MOJO_PUBLIC_C_SYSTEM_MACROS_H_ |
6 #define MOJO_PUBLIC_C_SYSTEM_MACROS_H_ | 6 #define MOJO_PUBLIC_C_SYSTEM_MACROS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 // Annotate a variable indicating it's okay if it's unused. | 10 // Annotate a variable indicating it's okay if it's unused. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 #else | 66 #else |
67 #error "Please define MOJO_ALIGNOF() for your compiler." | 67 #error "Please define MOJO_ALIGNOF() for your compiler." |
68 #endif | 68 #endif |
69 | 69 |
70 // Specify the alignment of a |struct|, etc. | 70 // Specify the alignment of a |struct|, etc. |
71 // Use like: | 71 // Use like: |
72 // struct MOJO_ALIGNAS(8) Foo { ... }; | 72 // struct MOJO_ALIGNAS(8) Foo { ... }; |
73 // Unlike the C++11 |alignas()|, |alignment| must be an integer. It may not be a | 73 // Unlike the C++11 |alignas()|, |alignment| must be an integer. It may not be a |
74 // type, nor can it be an expression like |MOJO_ALIGNOF(type)| (due to the | 74 // type, nor can it be an expression like |MOJO_ALIGNOF(type)| (due to the |
75 // non-C++11 MSVS version). | 75 // non-C++11 MSVS version). |
76 #if __cplusplus >= 201103L | 76 #if __cplusplus >= 201103L && \ |
77 (defined(__clang__) || (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 >= 40800)) | |
viettrungluu
2014/07/29 17:47:28
What about future versions of MSVC? This would be
| |
77 #define MOJO_ALIGNAS(alignment) alignas(alignment) | 78 #define MOJO_ALIGNAS(alignment) alignas(alignment) |
78 #elif defined(__GNUC__) | 79 #elif defined(__GNUC__) |
79 #define MOJO_ALIGNAS(alignment) __attribute__((aligned(alignment))) | 80 #define MOJO_ALIGNAS(alignment) __attribute__((aligned(alignment))) |
80 #elif defined(_MSC_VER) | 81 #elif defined(_MSC_VER) |
81 #define MOJO_ALIGNAS(alignment) __declspec(align(alignment)) | 82 #define MOJO_ALIGNAS(alignment) __declspec(align(alignment)) |
82 #else | 83 #else |
83 #error "Please define MOJO_ALIGNAS() for your compiler." | 84 #error "Please define MOJO_ALIGNAS() for your compiler." |
84 #endif | 85 #endif |
85 | 86 |
86 #endif // MOJO_PUBLIC_C_SYSTEM_MACROS_H_ | 87 #endif // MOJO_PUBLIC_C_SYSTEM_MACROS_H_ |
OLD | NEW |