Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
export.hpp
Go to the documentation of this file.
1#pragma once
2
3// Cross-platform symbol visibility macros.
4// Each shared library defines ARIA_<MODULE>_BUILD when compiling its own sources.
5
6#if defined(_WIN32) || defined(__CYGWIN__)
7# define ARIA_EXPORT __declspec(dllexport)
8# define ARIA_IMPORT __declspec(dllimport)
9#else
10# define ARIA_EXPORT __attribute__((visibility("default")))
11# define ARIA_IMPORT __attribute__((visibility("default")))
12#endif
13
14// ABI module
15#if defined(ARIA_ABI_BUILD)
16# define ARIA_ABI_API ARIA_EXPORT
17#elif defined(ARIA_ABI_STATIC)
18// Static consumers do not import symbols from a DLL.
19# define ARIA_ABI_API
20#else
21# define ARIA_ABI_API ARIA_IMPORT
22#endif
23
24// Runtime module
25#if defined(ARIA_RUNTIME_BUILD)
26# define ARIA_RUNTIME_API ARIA_EXPORT
27#elif defined(ARIA_RUNTIME_STATIC)
28# define ARIA_RUNTIME_API
29#else
30# define ARIA_RUNTIME_API ARIA_IMPORT
31#endif
32
33// Binding module
34#if defined(ARIA_BINDING_BUILD)
35# define ARIA_BINDING_API ARIA_EXPORT
36#elif defined(ARIA_BINDING_STATIC)
37# define ARIA_BINDING_API
38#else
39# define ARIA_BINDING_API ARIA_IMPORT
40#endif
41
42// Core module (diagnostics/trace sink storage lives in runtime DLL)
43#if defined(ARIA_RUNTIME_BUILD)
44# define ARIA_CORE_API ARIA_EXPORT
45#elif defined(ARIA_RUNTIME_STATIC)
46# define ARIA_CORE_API
47#else
48# define ARIA_CORE_API ARIA_IMPORT
49#endif
50
51// Qt6 adapter module
52#if defined(ARIA_QT6_BUILD)
53# define ARIA_QT6_API ARIA_EXPORT
54#elif defined(ARIA_QT6_STATIC)
55# define ARIA_QT6_API
56#else
57# define ARIA_QT6_API ARIA_IMPORT
58#endif
59
60// HTTP adapter module
61#if defined(ARIA_HTTP_BUILD)
62# define ARIA_HTTP_API ARIA_EXPORT
63#elif defined(ARIA_HTTP_STATIC)
64# define ARIA_HTTP_API
65#else
66# define ARIA_HTTP_API ARIA_IMPORT
67#endif
68
69// JNI (Android) adapter module
70#if defined(ARIA_JNI_BUILD)
71# define ARIA_JNI_API ARIA_EXPORT
72#elif defined(ARIA_JNI_STATIC)
73# define ARIA_JNI_API
74#else
75# define ARIA_JNI_API ARIA_IMPORT
76#endif
77
78// Force-inline
79#if defined(_MSC_VER)
80# define ARIA_ALWAYS_INLINE __forceinline
81#else
82# define ARIA_ALWAYS_INLINE __attribute__((always_inline)) inline
83#endif
84
85// Branch-prediction hints.
86//
87// `__builtin_expect` is a GCC/Clang extension that MSVC does not provide.
88// We therefore use it only on compilers that support it, and degrade to a
89// plain expression elsewhere. The C++20 [[likely]] / [[unlikely]] attributes
90// cannot be used here because these macros are expanded inside ordinary
91// expressions (e.g. `if (ARIA_LIKELY(ptr)) ...`), not on statements.
92#if defined(__GNUC__) || defined(__clang__)
93# define ARIA_LIKELY(x) (__builtin_expect(!!(x), 1))
94# define ARIA_UNLIKELY(x) (__builtin_expect(!!(x), 0))
95#else
96# define ARIA_LIKELY(x) (!!(x))
97# define ARIA_UNLIKELY(x) (!!(x))
98#endif