SeqAn3 3.2.0-rc.1
The Modern C++ library for sequence analysis.
platform.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
8#pragma once
9
10#include <cinttypes>
11#include <ciso646> // makes _LIBCPP_VERSION available
12#include <cstddef> // makes __GLIBCXX__ available
13
19// macro cruft
21#define SEQAN3_STR_HELPER(x) #x
22#define SEQAN3_STR(x) SEQAN3_STR_HELPER(x)
24
25// ============================================================================
26// Documentation
27// ============================================================================
28
29// Doxygen related
30// this macro is a NO-OP unless doxygen parses it, in which case it resolves to the argument
31#ifndef SEQAN3_DOXYGEN_ONLY
32# define SEQAN3_DOXYGEN_ONLY(x)
33#endif
34
35// ============================================================================
36// Compiler support
37// ============================================================================
38
39#if defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)
40# error "SeqAn 3.1.x is the last version that supports GCC 7 and 8. Please upgrade your compiler or use 3.1.x."
41#endif // defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)
42
43// ============================================================================
44// C++ standard and features
45// ============================================================================
46
47#if SEQAN3_DOXYGEN_ONLY(1)0
49#define SEQAN3_DISABLE_CPP17_DIAGNOSTIC
50#endif // SEQAN3_DOXYGEN_ONLY(1)0
51
52// C++ standard [required]
53#ifdef __cplusplus
54# if (__cplusplus < 201703)
55# error "SeqAn3 requires C++20, make sure that you have set -std=c++2a (gcc9) or -std=c++20 (gcc10 and higher)."
56# elif not defined(SEQAN3_DISABLE_CPP17_DIAGNOSTIC) && (__cplusplus >= 201703) && (__cplusplus < 201709)
57# pragma GCC warning "SeqAn 3.1.x is the last version that supports C++17. Newer SeqAn versions, including this one, might not compile with -std=c++17. To disable this warning, use -std=c++2a (gcc9), -std=c++20 (gcc10 and higher), or -DSEQAN3_DISABLE_CPP17_DIAGNOSTIC."
58# endif
59#else
60# error "This is not a C++ compiler."
61#endif
62
63// C++ Concepts [required]
64#ifndef __cpp_concepts
65# error "SeqAn3 requires C++ Concepts, either via -fconcepts (gcc9), or -std=c++20 (gcc10 and higher)."
66#endif
67
68#if __has_include(<version>)
69# include <version>
70#endif
71
73#if defined(__GNUC__) && (__GNUC__ < 10)
74# define SEQAN3_RETURN_TYPE_CONSTRAINT(expression, concept_name, ...) \
75 {expression}; requires concept_name<decltype(expression), __VA_ARGS__>
76#else
77# define SEQAN3_RETURN_TYPE_CONSTRAINT(expression, concept_name, ...) \
78 {expression} -> concept_name<__VA_ARGS__>
79#endif
80
81// ============================================================================
82// Dependencies
83// ============================================================================
84
85// SeqAn [required]
86#if __has_include(<seqan3/version.hpp>)
87# include <seqan3/version.hpp>
88#else
89# error SeqAn3 include directory not set correctly. Forgot to add -I ${INSTALLDIR}/include to your CXXFLAGS?
90#endif
91
92// Ranges [required]
93#if __has_include(<range/v3/version.hpp>)
94# define RANGE_V3_MINVERSION 1100
95# define RANGE_V3_MAXVERSION 1199
96// TODO the following doesn't actually show the current version, only its formula. How'd you do it?
97# define SEQAN3_MSG "Your version: " SEQAN3_STR(RANGE_V3_VERSION) \
98 "; minimum version: " SEQAN3_STR(RANGE_V3_MINVERSION) \
99 "; expected maximum version: " SEQAN3_STR(RANGE_V3_MAXVERSION)
100# include <range/v3/version.hpp>
101# if RANGE_V3_VERSION < RANGE_V3_MINVERSION
102# error Your range-v3 library is too old.
103# pragma message(SEQAN3_MSG)
104# elif RANGE_V3_VERSION > RANGE_V3_MAXVERSION
105# pragma GCC warning "Your range-v3 library is possibly too new. Some features might not work correctly."
106# pragma message(SEQAN3_MSG)
107# endif
108# undef SEQAN3_MSG
109#else
110# error The range-v3 library was not included correctly. Forgot to add -I ${INSTALLDIR}/include to your CXXFLAGS?
111#endif
112
113// SDSL [required]
114#if __has_include(<sdsl/version.hpp>)
115# include <sdsl/version.hpp>
116 static_assert(sdsl::sdsl_version_major == 3, "Only version 3 of the SDSL is supported by SeqAn3.");
117#else
118# error The sdsl library was not included correctly. Forgot to add -I ${INSTALLDIR}/include to your CXXFLAGS?
119#endif
120
121// Cereal [optional]
126#ifndef SEQAN3_WITH_CEREAL
127# if __has_include(<cereal/cereal.hpp>)
128# define SEQAN3_WITH_CEREAL 1
129# else
130# define SEQAN3_WITH_CEREAL 0
131# endif
132#elif SEQAN3_WITH_CEREAL != 0
133# if ! __has_include(<cereal/cereal.hpp>)
134# error Cereal was marked as required, but not found!
135# endif
136#endif
137
138#if !SEQAN3_WITH_CEREAL
147# define CEREAL_SERIALIZE_FUNCTION_NAME serialize
149# define CEREAL_LOAD_FUNCTION_NAME load
151# define CEREAL_SAVE_FUNCTION_NAME save
153# define CEREAL_LOAD_MINIMAL_FUNCTION_NAME load_minimal
155# define CEREAL_SAVE_MINIMAL_FUNCTION_NAME save_minimal
159#endif
160
161// Lemon [optional]
166#ifndef SEQAN3_WITH_LEMON
167# if __has_include(<lemon/config.h>)
168# define SEQAN3_WITH_LEMON 1
169# else
170# define SEQAN3_WITH_LEMON 0
171# endif
172#elif SEQAN3_WITH_LEMON != 0
173# if !__has_include(<lemon/config.h>)
174# error Lemon was marked as required, but not found!
175# endif
176#endif
177#if SEQAN3_WITH_LEMON == 1
178# define LEMON_HAVE_LONG_LONG 1
179# define LEMON_CXX11 1
180# if defined(__unix__) || defined(__APPLE__)
181# define LEMON_USE_PTHREAD 1
182# define LEMON_USE_WIN32_THREADS 0
183# define LEMON_WIN32 0
184# else
185# define LEMON_USE_PTHREAD 0
186# define LEMON_USE_WIN32_THREADS 1
187# define LEMON_WIN32 1
188# endif
189#endif
190
191// TODO (doesn't have a version.hpp, yet)
192
193// ============================================================================
194// Deprecation Messages
195// ============================================================================
196
198#ifndef SEQAN3_PRAGMA
199# define SEQAN3_PRAGMA(non_string_literal) _Pragma(#non_string_literal)
200#endif
201
203#ifndef SEQAN3_DEPRECATED_HEADER
204# ifndef SEQAN3_DISABLE_DEPRECATED_WARNINGS
205# define SEQAN3_DEPRECATED_HEADER(message) SEQAN3_PRAGMA(GCC warning message)
206# else
207# define SEQAN3_DEPRECATED_HEADER(message)
208# endif
209#endif
210
211// ============================================================================
212// Workarounds
213// ============================================================================
214
221#if defined(__GNUC__) && (__GNUC__ == 10 && __GNUC_MINOR__ <= 1)
222# pragma GCC warning "Be aware that gcc 10.0 and 10.1 are known to have several bugs that might make SeqAn3 fail to compile. Please use gcc >= 10.2."
223#endif // defined(__GNUC__) && (__GNUC__ == 10 && __GNUC_MINOR__ <= 1)
224
225#ifndef SEQAN3_WORKAROUND_VIEW_PERFORMANCE
227# define SEQAN3_WORKAROUND_VIEW_PERFORMANCE 1
228#endif
229
231#ifndef SEQAN3_WORKAROUND_ISSUE_286
232# if defined(__GNUC__) && (__GNUC__ <= 9)
233# define SEQAN3_WORKAROUND_ISSUE_286 1
234# else
235# define SEQAN3_WORKAROUND_ISSUE_286 0
236# endif
237#endif
238
240#ifndef SEQAN3_WORKAROUND_GCC_89953
241# if defined(__GNUC_MINOR__) && (__GNUC__ == 9 && __GNUC_MINOR__ < 3)
242# define SEQAN3_WORKAROUND_GCC_89953 1
243# else
244# define SEQAN3_WORKAROUND_GCC_89953 0
245# endif
246#endif
247
249#ifndef SEQAN3_WORKAROUND_GCC_93467 // fixed since gcc10.2
250# if defined(__GNUC__) && ((__GNUC__ <= 9) || (__GNUC__ == 10 && __GNUC_MINOR__ < 2))
251# define SEQAN3_WORKAROUND_GCC_93467 1
252# else
253# define SEQAN3_WORKAROUND_GCC_93467 0
254# endif
255#endif
256
258#ifndef SEQAN3_WORKAROUND_GCC_96070 // fixed since gcc10.4
259# if defined(__GNUC__) && (__GNUC__ == 10 && __GNUC_MINOR__ < 4)
260# define SEQAN3_WORKAROUND_GCC_96070 1
261# else
262# define SEQAN3_WORKAROUND_GCC_96070 0
263# endif
264#endif
265
267#ifndef SEQAN3_WORKAROUND_GCC_99318 // fixed since gcc10.3
268# if defined(__GNUC__) && (__GNUC__ == 10 && __GNUC_MINOR__ < 3)
269# define SEQAN3_WORKAROUND_GCC_99318 1
270# else
271# define SEQAN3_WORKAROUND_GCC_99318 0
272# endif
273#endif
274
277#ifndef SEQAN3_WORKAROUND_GCC_100139 // not yet fixed
278# if defined(__GNUC__)
279# define SEQAN3_WORKAROUND_GCC_100139 1
280# else
281# define SEQAN3_WORKAROUND_GCC_100139 0
282# endif
283#endif
284
295#ifndef SEQAN3_WORKAROUND_GCC_NO_CXX11_ABI
296# if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
297# define SEQAN3_WORKAROUND_GCC_NO_CXX11_ABI 1
298# else
299# define SEQAN3_WORKAROUND_GCC_NO_CXX11_ABI 0
300# endif
301#endif
302
303#if SEQAN3_DOXYGEN_ONLY(1)0
305#define SEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC
306#endif // SEQAN3_DOXYGEN_ONLY(1)0
307
308#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
309# ifndef SEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC
310# pragma GCC warning "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/seqan/3-master-user/about_api.html#platform_stability for more details). You can disable this warning by setting -DSEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC."
311# endif // SEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC
312#endif // _GLIBCXX_USE_CXX11_ABI == 0
313
317#ifndef SEQAN3_WORKAROUND_GCC_NON_TEMPLATE_REQUIRES
318# if defined(__GNUC_MINOR__) && (__GNUC__ < 10) // fixed since gcc-10
319# define SEQAN3_WORKAROUND_GCC_NON_TEMPLATE_REQUIRES 1
320# else
321# define SEQAN3_WORKAROUND_GCC_NON_TEMPLATE_REQUIRES 0
322# endif
323#endif
324
327#ifndef SEQAN3_WORKAROUND_GCC_PIPEABLE_CONFIG_CONCEPT
328# if defined(__GNUC__) && (__GNUC__ < 11)
329# define SEQAN3_WORKAROUND_GCC_PIPEABLE_CONFIG_CONCEPT 1
330# else
331# define SEQAN3_WORKAROUND_GCC_PIPEABLE_CONFIG_CONCEPT 0
332# endif
333#endif
334
354#ifndef SEQAN3_WORKAROUND_FURTHER_CONSTRAIN_FRIEND_DECLARATION
355# if defined(__clang__)
356# define SEQAN3_WORKAROUND_FURTHER_CONSTRAIN_FRIEND_DECLARATION 1
357# else
358# define SEQAN3_WORKAROUND_FURTHER_CONSTRAIN_FRIEND_DECLARATION 0
359# endif
360#endif
361
362// ============================================================================
363// Backmatter
364// ============================================================================
365
366// macro cruft undefine
367#undef SEQAN3_STR
368#undef SEQAN3_STR_HELPER
Provides SeqAn version macros and global variables.