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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
/*
* ZXC - High-performance lossless compression
*
* Copyright (c) 2025-2026 Bertrand Lebonnois and contributors.
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* @file zxc_export.h
* @brief Platform-specific symbol visibility macros.
*
* This header defines the `ZXC_EXPORT`, `ZXC_NO_EXPORT`, and `ZXC_DEPRECATED`
* macros that control which symbols are exported from the shared library.
*
* - Define @c ZXC_STATIC_DEFINE when building or consuming ZXC as a **static**
* library to disable import/export annotations.
* - When building the shared library the CMake target defines
* @c zxc_lib_EXPORTS automatically, selecting `dllexport` / `visibility("default")`.
* - When consuming the shared library neither macro is defined, so the header
* selects `dllimport` / `visibility("default")`.
*/
#ifndef ZXC_EXPORT_H
#define ZXC_EXPORT_H
/**
* @defgroup export Symbol Visibility
* @brief Macros controlling DLL export/import and deprecation attributes.
* @{
*/
#ifdef ZXC_STATIC_DEFINE
/**
* @def ZXC_EXPORT
* @brief Marks a symbol as part of the public shared-library API.
*
* Expands to nothing when building a static library (@c ZXC_STATIC_DEFINE),
* to `__declspec(dllexport)` or `__declspec(dllimport)` on Windows, or
* to `__attribute__((visibility("default")))` on GCC/Clang.
*/
#define ZXC_EXPORT
/**
* @def ZXC_NO_EXPORT
* @brief Marks a symbol as hidden (not exported from the shared library).
*
* Expands to nothing for static builds or Windows, and to
* `__attribute__((visibility("hidden")))` on GCC/Clang.
*/
#define ZXC_NO_EXPORT
#else /* shared library */
#ifndef ZXC_EXPORT
#ifdef zxc_lib_EXPORTS
/* Building the library */
#ifdef _WIN32
#define ZXC_EXPORT __declspec(dllexport)
#else
#define ZXC_EXPORT __attribute__((visibility("default")))
#endif
#else
/* Consuming the library */
#ifdef _WIN32
#define ZXC_EXPORT __declspec(dllimport)
#else
#define ZXC_EXPORT __attribute__((visibility("default")))
#endif
#endif
#endif
#ifndef ZXC_NO_EXPORT
#ifdef _WIN32
#define ZXC_NO_EXPORT
#else
#define ZXC_NO_EXPORT __attribute__((visibility("hidden")))
#endif
#endif
#endif /* ZXC_STATIC_DEFINE */
#ifndef ZXC_DEPRECATED
/**
* @def ZXC_DEPRECATED
* @brief Marks a symbol as deprecated.
*
* The compiler will emit a warning when a deprecated symbol is referenced.
* Expands to `__declspec(deprecated)` on MSVC or
* `__attribute__((__deprecated__))` on GCC/Clang.
*/
#ifdef _WIN32
#define ZXC_DEPRECATED __declspec(deprecated)
#else
#define ZXC_DEPRECATED __attribute__((__deprecated__))
#endif
#endif
/**
* @def ZXC_DEPRECATED_EXPORT
* @brief Combines `ZXC_EXPORT` with `ZXC_DEPRECATED`.
*/
#ifndef ZXC_DEPRECATED_EXPORT
#define ZXC_DEPRECATED_EXPORT ZXC_EXPORT ZXC_DEPRECATED
#endif
/**
* @def ZXC_DEPRECATED_NO_EXPORT
* @brief Combines `ZXC_NO_EXPORT` with `ZXC_DEPRECATED`.
*/
#ifndef ZXC_DEPRECATED_NO_EXPORT
#define ZXC_DEPRECATED_NO_EXPORT ZXC_NO_EXPORT ZXC_DEPRECATED
#endif
/** @} */ /* end of export */
#endif /* ZXC_EXPORT_H */
|