-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcommon.h
47 lines (39 loc) · 1.75 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef SIGNALSMITH_DSP_COMMON_H
#define SIGNALSMITH_DSP_COMMON_H
#if defined(__FAST_MATH__) && (__apple_build_version__ >= 16000000) && (__apple_build_version__ <= 16000099)
# error Apple Clang 16.0.0 generates incorrect SIMD for ARM. If you HAVE to use this version of Clang, turn off -ffast-math.
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288
#endif
namespace signalsmith {
/** @defgroup Common Common
@brief Definitions and helper classes used by the rest of the library
@{
@file
*/
#define SIGNALSMITH_DSP_VERSION_MAJOR 1
#define SIGNALSMITH_DSP_VERSION_MINOR 6
#define SIGNALSMITH_DSP_VERSION_PATCH 1
#define SIGNALSMITH_DSP_VERSION_STRING "1.6.1"
/** Version compatability check.
\code{.cpp}
static_assert(signalsmith::version(1, 4, 1), "version check");
\endcode
... or use the equivalent `SIGNALSMITH_DSP_VERSION_CHECK`.
Major versions are not compatible with each other. Minor and patch versions are backwards-compatible.
*/
constexpr bool versionCheck(int major, int minor, int patch=0) {
return major == SIGNALSMITH_DSP_VERSION_MAJOR
&& (SIGNALSMITH_DSP_VERSION_MINOR > minor
|| (SIGNALSMITH_DSP_VERSION_MINOR == minor && SIGNALSMITH_DSP_VERSION_PATCH >= patch));
}
/// Check the library version is compatible (semver).
#define SIGNALSMITH_DSP_VERSION_CHECK(major, minor, patch) \
static_assert(::signalsmith::versionCheck(major, minor, patch), "signalsmith library version is " SIGNALSMITH_DSP_VERSION_STRING);
/** @} */
} // signalsmith::
#else
// If we've already included it, check it's the same version
static_assert(SIGNALSMITH_DSP_VERSION_MAJOR == 1 && SIGNALSMITH_DSP_VERSION_MINOR == 6 && SIGNALSMITH_DSP_VERSION_PATCH == 1, "multiple versions of the Signalsmith DSP library");
#endif // include guard