DPC++ Runtime
Runtime libraries for oneAPI DPC++
defines_elementary.hpp
Go to the documentation of this file.
1 //==--- defines_elementary.hpp ---- Preprocessor directives (simplified) ---==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #define __SYCL_INLINE_VER_NAMESPACE(X) inline namespace X
12 
13 #ifndef __has_attribute
14 #define __has_attribute(x) 0
15 #endif
16 
17 #ifndef __has_builtin
18 #define __has_builtin(x) 0
19 #endif // __has_builtin
20 
21 #ifndef __SYCL_ALWAYS_INLINE
22 #if __has_attribute(always_inline)
23 #define __SYCL_ALWAYS_INLINE __attribute__((always_inline))
24 #else
25 #define __SYCL_ALWAYS_INLINE
26 #endif
27 #endif // __SYCL_ALWAYS_INLINE
28 
29 #ifndef SYCL_EXTERNAL
30 #define SYCL_EXTERNAL
31 #endif
32 
33 #ifndef __SYCL_ID_QUERIES_FIT_IN_INT__
34 #define __SYCL_ID_QUERIES_FIT_IN_INT__ 0
35 #endif
36 
37 #ifndef __SYCL_DEPRECATED
38 // The deprecated attribute is not supported in some situations(e.g. namespace)
39 // in C++14 mode
40 #if !defined(SYCL2020_DISABLE_DEPRECATION_WARNINGS) && __cplusplus >= 201703L
41 #define __SYCL_DEPRECATED(message) [[deprecated(message)]]
42 #else // SYCL_DISABLE_DEPRECATION_WARNINGS
43 #define __SYCL_DEPRECATED(message)
44 #endif // SYCL_DISABLE_DEPRECATION_WARNINGS
45 #endif // __SYCL_DEPRECATED
46 
47 #ifndef __SYCL2020_DEPRECATED
48 #if SYCL_LANGUAGE_VERSION >= 202001 && \
49  !defined(SYCL2020_DISABLE_DEPRECATION_WARNINGS)
50 #define __SYCL2020_DEPRECATED(message) __SYCL_DEPRECATED(message)
51 #else
52 #define __SYCL2020_DEPRECATED(message)
53 #endif
54 #endif // __SYCL2020_DEPRECATED
55 
56 #ifndef __SYCL_HAS_CPP_ATTRIBUTE
57 #if defined(__cplusplus) && defined(__has_cpp_attribute)
58 #define __SYCL_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
59 #else
60 #define __SYCL_HAS_CPP_ATTRIBUTE(x) 0
61 #endif
62 #endif
63 
64 #ifndef __SYCL_FALLTHROUGH
65 #if defined(__cplusplus) && __cplusplus >= 201703L && \
66  __SYCL_HAS_CPP_ATTRIBUTE(fallthrough)
67 #define __SYCL_FALLTHROUGH [[fallthrough]]
68 #elif __SYCL_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
69 #define __SYCL_FALLTHROUGH [[gnu::fallthrough]]
70 #elif __has_attribute(fallthrough)
71 #define __SYCL_FALLTHROUGH __attribute__((fallthrough))
72 #elif __SYCL_HAS_CPP_ATTRIBUTE(clang::fallthrough)
73 #define __SYCL_FALLTHROUGH [[clang::fallthrough]]
74 #else
75 #define __SYCL_FALLTHROUGH
76 #endif
77 #endif // __SYCL_FALLTHROUGH
78 
79 // Stringify an argument to pass it in _Pragma directive below.
80 #ifndef __SYCL_STRINGIFY
81 #define __SYCL_STRINGIFY(x) #x
82 #endif // __SYCL_STRINGIFY
83 
84 static_assert(__cplusplus >= 201703L,
85  "DPCPP does not support C++ version earlier than C++17.");