SeqAn3 3.4.0-rc.4
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
platform.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2025 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// zlib [optional]
113#ifndef SEQAN3_HAS_ZLIB
114# if __has_include(<zlib.h>)
115# define SEQAN3_HAS_ZLIB 1
116# else
117# define SEQAN3_HAS_ZLIB 0
118# endif
119#endif
120
121// bzip2 [optional]
126#ifndef SEQAN3_HAS_BZIP2
127# if SEQAN3_HAS_ZLIB && __has_include(<bzlib.h>)
128# define SEQAN3_HAS_BZIP2 1
129# else
130# define SEQAN3_HAS_BZIP2 0
131# endif
132#endif
133
134// Cereal [optional]
139#ifndef SEQAN3_HAS_CEREAL
140# if __has_include(<cereal/cereal.hpp>)
141# define SEQAN3_HAS_CEREAL 1
142# else
143# define SEQAN3_HAS_CEREAL 0
144# endif
145#endif
146
148#if !SEQAN3_HAS_CEREAL
154# define CEREAL_SERIALIZE_FUNCTION_NAME serialize
155# define CEREAL_LOAD_FUNCTION_NAME load
156# define CEREAL_SAVE_FUNCTION_NAME save
157# define CEREAL_LOAD_MINIMAL_FUNCTION_NAME load_minimal
158# define CEREAL_SAVE_MINIMAL_FUNCTION_NAME save_minimal
160#endif
162
163// ============================================================================
164// Deprecation Messages
165// ============================================================================
166
168#ifndef SEQAN3_PRAGMA
169# define SEQAN3_PRAGMA(non_string_literal) _Pragma(#non_string_literal)
170#endif
171
173#ifndef SEQAN3_DEPRECATED_HEADER
174# ifndef SEQAN3_DISABLE_DEPRECATED_WARNINGS
175# define SEQAN3_DEPRECATED_HEADER(message) SEQAN3_PRAGMA(GCC warning message)
176# else
177# define SEQAN3_DEPRECATED_HEADER(message)
178# endif
179#endif
180
182#ifndef SEQAN3_REMOVE_DEPRECATED_340
183# ifndef SEQAN3_DEPRECATED_340
184# ifndef SEQAN3_DISABLE_DEPRECATED_WARNINGS
185# define SEQAN3_DEPRECATED_340 \
186 [[deprecated("This will be removed in SeqAn-3.4.0; please see the documentation.")]]
187# else
188# define SEQAN3_DEPRECATED_340
189# endif
190# endif
191#endif
192
194// clang-format off
195#if defined(SEQAN3_WITH_CEREAL) && defined(SEQAN3_HAS_CEREAL) && SEQAN3_WITH_CEREAL != SEQAN3_HAS_CEREAL
196# error "SEQAN3_WITH_CEREAL is deprecated and has been replaced by SEQAN3_HAS_CEREAL. These two macros do not expand to the same value. Please use SEQAN3_HAS_CEREAL."
197#endif
198#ifndef SEQAN3_DISABLE_DEPRECATED_WARNINGS
199# ifdef SEQAN3_WITH_CEREAL
200# pragma GCC warning "SEQAN3_WITH_CEREAL is deprecated and will be removed in the next version; please use SEQAN3_HAS_CEREAL instead."
201# else
202# define SEQAN3_WITH_CEREAL \
203 SEQAN3_PRAGMA(GCC warning "SEQAN3_WITH_CEREAL is deprecated and will be removed in the next version; please use SEQAN3_HAS_CEREAL instead.") \
204 SEQAN3_HAS_CEREAL
205# endif
206#else
207# ifndef SEQAN3_WITH_CEREAL
208# define SEQAN3_WITH_CEREAL SEQAN3_HAS_CEREAL
209# endif
210#endif
211// clang-format on
213
214// ============================================================================
215// Workarounds
216// ============================================================================
217
218#ifndef SEQAN3_WORKAROUND_VIEW_PERFORMANCE
220# define SEQAN3_WORKAROUND_VIEW_PERFORMANCE 1
221#endif
222
223#ifndef SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
224# if SEQAN3_COMPILER_IS_GCC
225// For checking whether workaround applies, e.g., in search_scheme_test
226# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY 1
227// The goal is to create _Pragma("GCC diagnostic ignored \"-Wrestrict\"")
228// The outer quotes are added by SEQAN3_PRAGMA, so we need SEQAN3_PRAGMA(GCC diagnostic ignored "-Wrestrict")
229// SEQAN3_CONCAT_STRING(GCC diagnostic ignored, -Wrestrict) -> SEQAN3_PRAGMA(GCC diagnostic ignored "-Wrestrict")
230# define SEQAN3_CONCAT_STRING(x, y) SEQAN3_PRAGMA(x #y)
231# define SEQAN3_GCC_DIAGNOSTIC_IGNORE1(x, ...) \
232 SEQAN3_PRAGMA(GCC diagnostic push) \
233 SEQAN3_CONCAT_STRING(GCC diagnostic ignored, x)
234# define SEQAN3_GCC_DIAGNOSTIC_IGNORE2(x, y) \
235 SEQAN3_PRAGMA(GCC diagnostic push) \
236 SEQAN3_CONCAT_STRING(GCC diagnostic ignored, x) \
237 SEQAN3_CONCAT_STRING(GCC diagnostic ignored, y)
238// A helper that enables SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START to take one or two arguments
239// SEQAN3_GCC_DIAGNOSTIC_IGNORE(-Wrestict, 2, 1) -> SEQAN3_GCC_DIAGNOSTIC_IGNORE1(-Wrestict, 2)
240// SEQAN3_GCC_DIAGNOSTIC_IGNORE(-Wrestict, -Warray-bounds, 2, 1) -> SEQAN3_GCC_DIAGNOSTIC_IGNORE2(-Wrestict, -Warray-bounds)
241# define SEQAN3_GCC_DIAGNOSTIC_IGNORE(x, y, n, ...) SEQAN3_GCC_DIAGNOSTIC_IGNORE##n(x, y)
242// SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Wrestrict) -> SEQAN3_GCC_DIAGNOSTIC_IGNORE(-Wrestict, 2, 1)
243// SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Wrestrict, -Warray-bounds) -> SEQAN3_GCC_DIAGNOSTIC_IGNORE(-Wrestict, -Warray-bounds, 2, 1)
244# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(x, ...) SEQAN3_GCC_DIAGNOSTIC_IGNORE(x, ##__VA_ARGS__, 2, 1)
245# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP SEQAN3_PRAGMA(GCC diagnostic pop)
246# else
251# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY 0
268# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(...)
277# define SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP
279# endif
280#endif
281
292#ifndef SEQAN3_WORKAROUND_GCC_NO_CXX11_ABI
293# if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
294# define SEQAN3_WORKAROUND_GCC_NO_CXX11_ABI 1
295# else
296# define SEQAN3_WORKAROUND_GCC_NO_CXX11_ABI 0
297# endif
298#endif
299
307#if __cpp_lib_constexpr_vector >= 201907L && (defined(_LIBCPP_VERSION) || !defined(_GLIBCXX_DEBUG))
308# define SEQAN3_WORKAROUND_LITERAL constexpr
309#else
310# define SEQAN3_WORKAROUND_LITERAL inline
311#endif
312
313#if SEQAN3_DOXYGEN_ONLY(1) 0
315# define SEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC
316#endif // SEQAN3_DOXYGEN_ONLY(1)0
317
318#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
319# ifndef SEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC
320# pragma message \
321 "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."
322# endif // SEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC
323#endif // _GLIBCXX_USE_CXX11_ABI == 0
324
325// ============================================================================
326// Backmatter
327// ============================================================================
328
329// macro cruft undefine
330#undef SEQAN3_STR
331#undef SEQAN3_STR_HELPER
Provides SeqAn version macros and global variables.
Hide me