SeqAn3 3.4.0-rc.3
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
platform.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <version>
13
14// macro cruft
16#define SEQAN3_STR_HELPER(x) #x
17#define SEQAN3_STR(x) SEQAN3_STR_HELPER(x)
19
20// ============================================================================
21// Documentation
22// ============================================================================
23
24// Doxygen related
25// this macro is a NO-OP unless doxygen parses it, in which case it resolves to the argument
26#ifndef SEQAN3_DOXYGEN_ONLY
27# define SEQAN3_DOXYGEN_ONLY(x)
28#endif
29
30// ============================================================================
31// Compiler support general
32// ============================================================================
33
43#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
44# define SEQAN3_COMPILER_IS_GCC 1
45#else
46# define SEQAN3_COMPILER_IS_GCC 0
47#endif
48
49#if SEQAN3_DOXYGEN_ONLY(1) 0
51# define SEQAN3_DISABLE_COMPILER_CHECK
52#endif // SEQAN3_DOXYGEN_ONLY(1)0
53
54// ============================================================================
55// Compiler support
56// ============================================================================
57
58#if SEQAN3_COMPILER_IS_GCC && (__GNUC__ < 12)
59# error "At least GCC 12 is needed."
60#endif
61
62// clang-format off
63#if defined(__INTEL_LLVM_COMPILER) && (__INTEL_LLVM_COMPILER < 20240000)
64# error "At least Intel OneAPI 2024 is needed."
65#endif
66// clang-format on
67
68#if defined(__clang__) && defined(__clang_major__) && (__clang_major__ < 17)
69# error "At least Clang 17 is needed."
70#endif
71
72// ============================================================================
73// Standard library support
74// ============================================================================
75
76#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 170000)
77# error "At least libc++ 17 is required."
78#endif
79
80#if defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 12)
81# error "At least libstdc++ 12 is needed."
82#endif
83
84// ============================================================================
85// C++ standard and features
86// ============================================================================
87
88// C++ standard [required]
89#ifdef __cplusplus
90# if (__cplusplus < 202100)
91# error "SeqAn3 requires C++23, make sure that you have set -std=c++23."
92# endif
93#else
94# error "This is not a C++ compiler."
95#endif
96
97// ============================================================================
98// Dependencies
99// ============================================================================
100
101// SeqAn [required]
102#if __has_include(<seqan3/version.hpp>)
103# include <seqan3/version.hpp>
104#else
105# error SeqAn3 include directory not set correctly. Forgot to add -I ${INSTALLDIR}/include to your CXXFLAGS?
106#endif
107
108// SDSL [required]
109#if __has_include(<sdsl/version.hpp>)
110# include <sdsl/version.hpp>
111static_assert(sdsl::sdsl_version_major == 3, "Only version 3 of the SDSL is supported by SeqAn3.");
112#else
113# error The sdsl library was not included correctly. Forgot to add -I ${INSTALLDIR}/include to your CXXFLAGS?
114#endif
115
116// Cereal [optional]
121#ifndef SEQAN3_WITH_CEREAL
122# if __has_include(<cereal/cereal.hpp>)
123# define SEQAN3_WITH_CEREAL 1
124# else
125# define SEQAN3_WITH_CEREAL 0
126# endif
127#elif SEQAN3_WITH_CEREAL != 0
128# if !__has_include(<cereal/cereal.hpp>)
129# error Cereal was marked as required, but not found!
130# endif
131#endif
132
134#if !SEQAN3_WITH_CEREAL
140# define CEREAL_SERIALIZE_FUNCTION_NAME serialize
141# define CEREAL_LOAD_FUNCTION_NAME load
142# define CEREAL_SAVE_FUNCTION_NAME save
143# define CEREAL_LOAD_MINIMAL_FUNCTION_NAME load_minimal
144# define CEREAL_SAVE_MINIMAL_FUNCTION_NAME save_minimal
146#endif
148
149// ============================================================================
150// Deprecation Messages
151// ============================================================================
152
154#ifndef SEQAN3_PRAGMA
155# define SEQAN3_PRAGMA(non_string_literal) _Pragma(#non_string_literal)
156#endif
157
159#ifndef SEQAN3_DEPRECATED_HEADER
160# ifndef SEQAN3_DISABLE_DEPRECATED_WARNINGS
161# define SEQAN3_DEPRECATED_HEADER(message) SEQAN3_PRAGMA(GCC warning message)
162# else
163# define SEQAN3_DEPRECATED_HEADER(message)
164# endif
165#endif
166
168#ifndef SEQAN3_REMOVE_DEPRECATED_340
169# ifndef SEQAN3_DEPRECATED_340
170# ifndef SEQAN3_DISABLE_DEPRECATED_WARNINGS
171# define SEQAN3_DEPRECATED_340 \
172 [[deprecated("This will be removed in SeqAn-3.4.0; please see the documentation.")]]
173# else
174# define SEQAN3_DEPRECATED_340
175# endif
176# endif
177#endif
178
179// ============================================================================
180// Workarounds
181// ============================================================================
182
183#ifndef SEQAN3_WORKAROUND_VIEW_PERFORMANCE
185# define SEQAN3_WORKAROUND_VIEW_PERFORMANCE 1
186#endif
187
189#ifndef SEQAN3_WORKAROUND_DEFAULT_CONSTRUCTIBLE_VIEW
190# if SEQAN3_COMPILER_IS_GCC && (__GNUC__ < 12)
191# define SEQAN3_WORKAROUND_DEFAULT_CONSTRUCTIBLE_VIEW 1
192# else
193# define SEQAN3_WORKAROUND_DEFAULT_CONSTRUCTIBLE_VIEW 0
194# endif
195#endif
196
199#ifndef SEQAN3_WORKAROUND_GCC_100139
200# if SEQAN3_COMPILER_IS_GCC && (__GNUC__ < 12)
201# define SEQAN3_WORKAROUND_GCC_100139 1
202# else
203# define SEQAN3_WORKAROUND_GCC_100139 0
204# endif
205#endif
206
207#ifndef SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
208# if SEQAN3_COMPILER_IS_GCC && (__GNUC__ >= 12)
209// For checking whether workaround applies, e.g., in search_scheme_test
210# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY 1
211// The goal is to create _Pragma("GCC diagnostic ignored \"-Wrestrict\"")
212// The outer quotes are added by SEQAN3_PRAGMA, so we need SEQAN3_PRAGMA(GCC diagnostic ignored "-Wrestrict")
213// SEQAN3_CONCAT_STRING(GCC diagnostic ignored, -Wrestrict) -> SEQAN3_PRAGMA(GCC diagnostic ignored "-Wrestrict")
214# define SEQAN3_CONCAT_STRING(x, y) SEQAN3_PRAGMA(x #y)
215# define SEQAN3_GCC_DIAGNOSTIC_IGNORE1(x, ...) \
216 SEQAN3_PRAGMA(GCC diagnostic push) \
217 SEQAN3_CONCAT_STRING(GCC diagnostic ignored, x)
218# define SEQAN3_GCC_DIAGNOSTIC_IGNORE2(x, y) \
219 SEQAN3_PRAGMA(GCC diagnostic push) \
220 SEQAN3_CONCAT_STRING(GCC diagnostic ignored, x) \
221 SEQAN3_CONCAT_STRING(GCC diagnostic ignored, y)
222// A helper that enables SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START to take one or two arguments
223// SEQAN3_GCC_DIAGNOSTIC_IGNORE(-Wrestict, 2, 1) -> SEQAN3_GCC_DIAGNOSTIC_IGNORE1(-Wrestict, 2)
224// SEQAN3_GCC_DIAGNOSTIC_IGNORE(-Wrestict, -Warray-bounds, 2, 1) -> SEQAN3_GCC_DIAGNOSTIC_IGNORE2(-Wrestict, -Warray-bounds)
225# define SEQAN3_GCC_DIAGNOSTIC_IGNORE(x, y, n, ...) SEQAN3_GCC_DIAGNOSTIC_IGNORE##n(x, y)
226// SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Wrestrict) -> SEQAN3_GCC_DIAGNOSTIC_IGNORE(-Wrestict, 2, 1)
227// SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Wrestrict, -Warray-bounds) -> SEQAN3_GCC_DIAGNOSTIC_IGNORE(-Wrestict, -Warray-bounds, 2, 1)
228# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(x, ...) SEQAN3_GCC_DIAGNOSTIC_IGNORE(x, ##__VA_ARGS__, 2, 1)
229# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP SEQAN3_PRAGMA(GCC diagnostic pop)
230# else
235# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY 0
252# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(...)
261# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP
263# endif
264#endif
265
276#ifndef SEQAN3_WORKAROUND_GCC_NO_CXX11_ABI
277# if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
278# define SEQAN3_WORKAROUND_GCC_NO_CXX11_ABI 1
279# else
280# define SEQAN3_WORKAROUND_GCC_NO_CXX11_ABI 0
281# endif
282#endif
283
291#if __cpp_lib_constexpr_vector >= 201907L && (defined(_LIBCPP_VERSION) || !defined(_GLIBCXX_DEBUG))
292# define SEQAN3_WORKAROUND_LITERAL constexpr
293#else
294# define SEQAN3_WORKAROUND_LITERAL inline
295#endif
296
297#if SEQAN3_DOXYGEN_ONLY(1) 0
299# define SEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC
300#endif // SEQAN3_DOXYGEN_ONLY(1)0
301
302#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
303# ifndef SEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC
304# pragma message \
305 "We do not actively support compiler that have -D_GLIBCXX_USE_CXX11_ABI=0 set, and it might be that SeqAn does not compile due to this. It is known that all compiler of CentOS 7 / RHEL 7 set this flag by default (and that it cannot be overridden!). Note that these versions of the OSes are community-supported (see https://docs.seqan.de/seqan3/main_user/about_api.html#platform_stability for more details). You can disable this warning by setting -DSEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC."
306# endif // SEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC
307#endif // _GLIBCXX_USE_CXX11_ABI == 0
308
309// ============================================================================
310// Backmatter
311// ============================================================================
312
313// macro cruft undefine
314#undef SEQAN3_STR
315#undef SEQAN3_STR_HELPER
Provides SeqAn version macros and global variables.
Hide me