numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
compiler_builtins.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22// IWYU pragma: no_include <string_view>
23
24/* ***********************************************************************
25 * NUM_COLLECT_HAS_MSVC_SOURCE_LOCATION macro.
26 * ***********************************************************************/
27
28#if defined(NUM_COLLECT_DOCUMENTATION)
29
33#define NUM_COLLECT_HAS_MSVC_SOURCE_LOCATION 1
34
35#elif defined(_MSC_VER)
36
37// on MSVC
38#if _MSC_VER >= 1929
39// Visual Studio 2019 16.10 and later supports source location.
40// NOLINTNEXTLINE
41#define NUM_COLLECT_HAS_MSVC_SOURCE_LOCATION 1
42#else
43// NOLINTNEXTLINE
44#define NUM_COLLECT_HAS_MSVC_SOURCE_LOCATION 0
45#endif
46
47#else
48
49// Other than MSVC.
50// NOLINTNEXTLINE
51#define NUM_COLLECT_HAS_MSVC_SOURCE_LOCATION 0
52
53#endif
54
55/* ***********************************************************************
56 * NUM_COLLECT_HAS_BUILTIN macro.
57 * ***********************************************************************/
58
59#if defined(NUM_COLLECT_DOCUMENTATION)
60
68#define NUM_COLLECT_HAS_BUILTIN(NAME) __has_builtin(NAME)
69
70#elif defined(__has_builtin)
71// NOLINTNEXTLINE
72#define NUM_COLLECT_HAS_BUILTIN(NAME) __has_builtin(NAME)
73#else
74// NOLINTNEXTLINE
75#define NUM_COLLECT_HAS_BUILTIN(NAME) 0
76#endif
77
78/* ***********************************************************************
79 * NUM_COLLECT_HAS_BUILTIN_FILE, NUM_COLLECT_BUILTIN_FILE macros.
80 * ***********************************************************************/
81
82#if defined(NUM_COLLECT_DOCUMENTATION)
83
85#define NUM_COLLECT_HAS_BUILTIN_FILE 1
86
92#define NUM_COLLECT_BUILTIN_FILE() __builtin_FILE()
93
94#elif NUM_COLLECT_HAS_BUILTIN(__builtin_FILE) || \
95 NUM_COLLECT_HAS_MSVC_SOURCE_LOCATION
96// NOLINTNEXTLINE
97#define NUM_COLLECT_HAS_BUILTIN_FILE 1
98// NOLINTNEXTLINE
99#define NUM_COLLECT_BUILTIN_FILE() __builtin_FILE()
100#else
101// NOLINTNEXTLINE
102#define NUM_COLLECT_HAS_BUILTIN_FILE 0
103// NOLINTNEXTLINE
104#define NUM_COLLECT_BUILTIN_FILE() static_cast<const char*>("")
105#endif
106
107/* ***********************************************************************
108 * NUM_COLLECT_HAS_BUILTIN_FUNCTION, NUM_COLLECT_BUILTIN_FUNCTION macros.
109 * ***********************************************************************/
110
111#if defined(NUM_COLLECT_DOCUMENTATION)
112
114#define NUM_COLLECT_HAS_BUILTIN_FUNCTION 1
115
121#define NUM_COLLECT_BUILTIN_FUNCTION() __builtin_FUNCTION()
122
123#elif NUM_COLLECT_HAS_BUILTIN(__builtin_FUNCTION) || \
124 NUM_COLLECT_HAS_MSVC_SOURCE_LOCATION
125// NOLINTNEXTLINE
126#define NUM_COLLECT_HAS_BUILTIN_FUNCTION 1
127// NOLINTNEXTLINE
128#define NUM_COLLECT_BUILTIN_FUNCTION() __builtin_FUNCTION()
129#else
130// NOLINTNEXTLINE
131#define NUM_COLLECT_HAS_BUILTIN_FUNCTION 0
132// NOLINTNEXTLINE
133#define NUM_COLLECT_BUILTIN_FUNCTION() static_cast<const char*>("")
134#endif
135
136/* ***********************************************************************
137 * NUM_COLLECT_HAS_BUILTIN_LINE, NUM_COLLECT_BUILTIN_LINE macros.
138 * ***********************************************************************/
139
140#if defined(NUM_COLLECT_DOCUMENTATION)
141
143#define NUM_COLLECT_HAS_BUILTIN_LINE 1
144
150#define NUM_COLLECT_BUILTIN_LINE() __builtin_LINE()
151
152#elif NUM_COLLECT_HAS_BUILTIN(__builtin_LINE) || \
153 NUM_COLLECT_HAS_MSVC_SOURCE_LOCATION
154// NOLINTNEXTLINE
155#define NUM_COLLECT_HAS_BUILTIN_LINE 1
156// NOLINTNEXTLINE
157#define NUM_COLLECT_BUILTIN_LINE() __builtin_LINE()
158#else
159// NOLINTNEXTLINE
160#define NUM_COLLECT_HAS_BUILTIN_LINE 0
161// NOLINTNEXTLINE
162#define NUM_COLLECT_BUILTIN_LINE() 0
163#endif
164
165/* ***********************************************************************
166 * NUM_COLLECT_HAS_BUILTIN_COLUMN, NUM_COLLECT_BUILTIN_COLUMN macros.
167 * ***********************************************************************/
168
169#if defined(NUM_COLLECT_DOCUMENTATION)
170
172#define NUM_COLLECT_HAS_BUILTIN_COLUMN 1
173
179#define NUM_COLLECT_BUILTIN_COLUMN() __builtin_COLUMN()
180
181#elif NUM_COLLECT_HAS_BUILTIN(__builtin_COLUMN) || \
182 NUM_COLLECT_HAS_MSVC_SOURCE_LOCATION
183// NOLINTNEXTLINE
184#define NUM_COLLECT_HAS_BUILTIN_COLUMN 1
185// NOLINTNEXTLINE
186#define NUM_COLLECT_BUILTIN_COLUMN() __builtin_COLUMN()
187#else
188// NOLINTNEXTLINE
189#define NUM_COLLECT_HAS_BUILTIN_COLUMN 0
190// NOLINTNEXTLINE
191#define NUM_COLLECT_BUILTIN_COLUMN() 0
192#endif