HIBF 1.0.0-rc.1
All Classes Namespaces Files Functions Variables Typedefs Friends Macros Modules Pages Concepts
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// IWYU pragma: always_keep
13// IWYU pragma: begin_exports
14
15#include <version> // for __cpp_lib_constexpr_vector
16
17// IWYU pragma: end_exports
18
19// ============================================================================
20// Documentation
21// ============================================================================
22
23// Doxygen related
24// this macro is a NO-OP unless doxygen parses it, in which case it resolves to the argument
25#ifndef HIBF_DOXYGEN_ONLY
26# define HIBF_DOXYGEN_ONLY(x)
27#endif
28
29// ============================================================================
30// Compiler support general
31// ============================================================================
32
42#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
43# define HIBF_COMPILER_IS_GCC 1
44#else
45# define HIBF_COMPILER_IS_GCC 0
46#endif
47
52#ifndef HIBF_HAS_AVX512
53# if __AVX512F__ && __AVX512BW__
54# define HIBF_HAS_AVX512 1
55# else
56# define HIBF_HAS_AVX512 0
57# endif
58#endif
59
60// ============================================================================
61// Compiler support
62// ============================================================================
63
64#if HIBF_COMPILER_IS_GCC && (__GNUC__ < 12)
65# error "At least GCC 12 is needed."
66#endif
67
68#if defined(__INTEL_LLVM_COMPILER) && (__INTEL_LLVM_COMPILER < 20240000)
69# error "At least Intel OneAPI 2024 is needed."
70#endif
71
72#if defined(__clang__) && defined(__clang_major__) && (__clang_major__ < 17)
73# error "At least Clang 17 is needed."
74#endif
75
76// ============================================================================
77// Standard library support
78// ============================================================================
79
80#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 170000)
81# error "At least libc++ 17 is required."
82#endif
83
84#if defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 12)
85# error "At least libstdc++ 12 is needed."
86#endif
87
88// ============================================================================
89// C++ standard and features
90// ============================================================================
91
92// C++ standard [required]
93#ifdef __cplusplus
94# if (__cplusplus < 202100)
95# error "C++23 is required, make sure that you have set -std=c++23."
96# endif
97#else
98# error "This is not a C++ compiler."
99#endif
100
101// ============================================================================
102// Dependencies
103// ============================================================================
104
105// HIBF [required]
106#if __has_include(<hibf/version.hpp>)
107# include <hibf/version.hpp>
108#else
109# error "HIBF include directory not set correctly. Forgot to add -I ${INSTALLDIR}/include to your CXXFLAGS?"
110#endif
111
112// ============================================================================
113// Workarounds
114// ============================================================================
115
117#if defined(__cpp_lib_constexpr_vector)
118# define HIBF_CONSTEXPR_VECTOR constexpr
119#else
120# define HIBF_CONSTEXPR_VECTOR
121#endif
122
126#ifndef HIBF_WORKAROUND_GCC_BOGUS_MEMCPY
127# if HIBF_COMPILER_IS_GCC && (__GNUC__ == 12)
128# define HIBF_WORKAROUND_GCC_BOGUS_MEMCPY 1
129# else
130# define HIBF_WORKAROUND_GCC_BOGUS_MEMCPY 0
131# endif
132#endif
133
134#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
135# pragma message "We do not actively support compiler that have -D_GLIBCXX_USE_CXX11_ABI=0 set."
136#endif // _GLIBCXX_USE_CXX11_ABI == 0
Provides version macros and global variables.