HIBF 1.0.0-rc.1
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// macro cruft
14#define HIBF_STR_HELPER(x) #x
15#define HIBF_STR(x) HIBF_STR_HELPER(x)
17
18// ============================================================================
19// Documentation
20// ============================================================================
21
22// Doxygen related
23// this macro is a NO-OP unless doxygen parses it, in which case it resolves to the argument
24#ifndef HIBF_DOXYGEN_ONLY
25# define HIBF_DOXYGEN_ONLY(x)
26#endif
27
28// ============================================================================
29// Compiler support general
30// ============================================================================
31
41#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER)
42# define HIBF_COMPILER_IS_GCC 1
43#else
44# define HIBF_COMPILER_IS_GCC 0
45#endif
46
47#if HIBF_DOXYGEN_ONLY(1) 0
49# define HIBF_DISABLE_COMPILER_CHECK
50#endif // HIBF_DOXYGEN_ONLY(1)0
51
56#ifndef HIBF_HAS_AVX512
57# if __AVX512F__ && __AVX512BW__
58# define HIBF_HAS_AVX512 1
59# else
60# define HIBF_HAS_AVX512 0
61# endif
62#endif
63
64// ============================================================================
65// Compiler support GCC
66// ============================================================================
67
68#if HIBF_COMPILER_IS_GCC
69# if (__GNUC__ < 12)
70# error "At least GCC 12 is needed."
71# endif // (__GNUC__ < 12)
72
73# if (__GNUC__ == 12 && __GNUC_MINOR__ <= 2)
74# pragma warning "Be aware that GCC < 12.3 might have bugs that cause compile failure."
75# endif // (__GNUC__ == 12 && __GNUC_MINOR__ <= 2)
76
77# if HIBF_DOXYGEN_ONLY(1) 0
79# define HIBF_DISABLE_NEWER_COMPILER_DIAGNOSTIC
80# endif // HIBF_DOXYGEN_ONLY(1)0
81
82# ifndef HIBF_DISABLE_NEWER_COMPILER_DIAGNOSTIC
83# if (__GNUC__ > 14)
84# pragma message \
85 "Your compiler is newer than the latest supported compiler version (gcc-14). It might be that compiling fails. You can disable this warning by setting -DHIBF_DISABLE_NEWER_COMPILER_DIAGNOSTIC."
86# endif // (__GNUC__ > 14)
87# endif // HIBF_DISABLE_NEWER_COMPILER_DIAGNOSTIC
88#endif
89
90// ============================================================================
91// C++ standard and features
92// ============================================================================
93
94#if __has_include(<version>)
95# include <version> // for __cpp_lib_constexpr_vector
96#endif
97
98// C++ standard [required]
99#ifdef __cplusplus
100# if (__cplusplus < 202100)
101# error "C++23 is required, make sure that you have set -std=c++23."
102# endif
103#else
104# error "This is not a C++ compiler."
105#endif
106
107// ============================================================================
108// Dependencies
109// ============================================================================
110
111// HIBF [required]
112#if __has_include(<hibf/version.hpp>)
113# include <hibf/version.hpp>
114#else
115# error "HIBF include directory not set correctly. Forgot to add -I ${INSTALLDIR}/include to your CXXFLAGS?"
116#endif
117
118// ============================================================================
119// Deprecation Messages
120// ============================================================================
121
123#ifndef HIBF_PRAGMA
124# define HIBF_PRAGMA(non_string_literal) _Pragma(#non_string_literal)
125#endif
126
128#ifndef HIBF_DEPRECATED_HEADER
129# ifndef HIBF_DISABLE_DEPRECATED_WARNINGS
130# define HIBF_DEPRECATED_HEADER(message) HIBF_PRAGMA(GCC warning message)
131# else
132# define HIBF_DEPRECATED_HEADER(message)
133# endif
134#endif
135
137#ifndef HIBF_REMOVE_DEPRECATED_100
138# ifndef HIBF_DEPRECATED_100
139# ifndef HIBF_DISABLE_DEPRECATED_WARNINGS
140# define HIBF_DEPRECATED_100 \
141 [[deprecated("This will be removed in version 1.0.0; please see the documentation.")]]
142# else
143# define HIBF_DEPRECATED_100
144# endif
145# endif
146#endif
147
148// ============================================================================
149// Workarounds
150// ============================================================================
151
153#if defined(__cpp_lib_constexpr_vector)
154# define HIBF_CONSTEXPR_VECTOR constexpr
155#else
156# define HIBF_CONSTEXPR_VECTOR
157#endif
158
162#ifndef HIBF_WORKAROUND_GCC_BOGUS_MEMCPY
163# if HIBF_COMPILER_IS_GCC && (__GNUC__ == 12)
164# define HIBF_WORKAROUND_GCC_BOGUS_MEMCPY 1
165# else
166# define HIBF_WORKAROUND_GCC_BOGUS_MEMCPY 0
167# endif
168#endif
169
180#ifndef HIBF_WORKAROUND_GCC_NO_CXX11_ABI
181# if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
182# define HIBF_WORKAROUND_GCC_NO_CXX11_ABI 1
183# else
184# define HIBF_WORKAROUND_GCC_NO_CXX11_ABI 0
185# endif
186#endif
187
189#if defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L
190# define HIBF_WORKAROUND_LITERAL constexpr
191#else
192# define HIBF_WORKAROUND_LITERAL inline
193#endif
194
195#if HIBF_DOXYGEN_ONLY(1) 0
197# define HIBF_DISABLE_LEGACY_STD_DIAGNOSTIC
198#endif // HIBF_DOXYGEN_ONLY(1)0
199
200#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
201# ifndef HIBF_DISABLE_LEGACY_STD_DIAGNOSTIC
202# pragma message \
203 "We do not actively support compiler that have -D_GLIBCXX_USE_CXX11_ABI=0 set, and it might be that compiling fails. It is known that all compilers 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. You can disable this warning by setting -DHIBF_DISABLE_LEGACY_STD_DIAGNOSTIC."
204# endif // HIBF_DISABLE_LEGACY_STD_DIAGNOSTIC
205#endif // _GLIBCXX_USE_CXX11_ABI == 0
206
207// ============================================================================
208// Backmatter
209// ============================================================================
210
211// macro cruft undefine
212#undef HIBF_STR
213#undef HIBF_STR_HELPER
Provides version macros and global variables.