V8
head
Loading...
Searching...
No Matches
include
cppgc
internal
compiler-specific.h
Go to the documentation of this file.
1
// Copyright 2020 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_
6
#define INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_
7
8
#include "
v8config.h
"
// NOLINT(build/include_directory)
9
10
namespace
cppgc
{
11
12
#if defined(__has_attribute)
13
#define CPPGC_HAS_ATTRIBUTE(FEATURE) __has_attribute(FEATURE)
14
#else
15
#define CPPGC_HAS_ATTRIBUTE(FEATURE) 0
16
#endif
17
18
#if defined(__has_cpp_attribute)
19
#define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) __has_cpp_attribute(FEATURE)
20
#else
21
#define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) 0
22
#endif
23
24
// [[no_unique_address]] comes in C++20 but supported in clang with -std >=
25
// c++11.
26
#if defined(V8_CC_MSVC) && CPPGC_HAS_CPP_ATTRIBUTE(msvc::no_unique_address)
27
// Unfortunately MSVC ignores [[no_unique_address]] (see
28
// https://devblogs.microsoft.com/cppblog/msvc-cpp20-and-the-std-cpp20-switch/#msvc-extensions-and-abi),
29
// and clang-cl matches it for ABI compatibility reasons. We need to prefer
30
// [[msvc::no_unique_address]] when available if we actually want any effect.
31
#define CPPGC_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
32
#elif CPPGC_HAS_CPP_ATTRIBUTE(no_unique_address)
33
#define CPPGC_NO_UNIQUE_ADDRESS [[no_unique_address]]
34
#else
35
#define CPPGC_NO_UNIQUE_ADDRESS
36
#endif
37
38
#if CPPGC_HAS_ATTRIBUTE(unused)
39
#define CPPGC_UNUSED __attribute__((unused))
40
#else
41
#define CPPGC_UNUSED
42
#endif
43
44
}
// namespace cppgc
45
46
#endif
// INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_
cppgc
Definition:
allocation.h:38
v8config.h