Lance C/C++ Bindings
C ABI and header-only C++ RAII wrappers for the Lance columnar data format
Loading...
Searching...
No Matches
attributes.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: Apache-2.0 */
2/* SPDX-FileCopyrightText: Copyright The Lance Authors */
3
9#ifndef LANCE_ATTRIBUTES_H
10#define LANCE_ATTRIBUTES_H
11
12/* Marks declarations exported by the shared library. On Windows the default is
13 * an ordinary declaration, so one header works with both the static archive
14 * and the DLL import library. Define LANCE_C_SHARED when linking the DLL to
15 * use __declspec(dllimport), or LANCE_C_BUILDING_LIBRARY when building it. */
16#if defined(_WIN32)
17# if defined(LANCE_C_BUILDING_LIBRARY)
18# define LANCE_API __declspec(dllexport)
19# elif defined(LANCE_C_SHARED)
20# define LANCE_API __declspec(dllimport)
21# else
22# define LANCE_API
23# endif
24#elif defined(__GNUC__) || defined(__clang__)
25# define LANCE_API __attribute__((visibility("default")))
26#else
27# define LANCE_API
28#endif
29
30/* Compiler-enforced deprecation. The message names the replacement API. */
31#if defined(__cplusplus) && __cplusplus >= 201402L
32# define LANCE_DEPRECATED(message) [[deprecated(message)]]
33#elif defined(_MSC_VER)
34# define LANCE_DEPRECATED(message) __declspec(deprecated(message))
35#elif defined(__GNUC__) || defined(__clang__)
36# define LANCE_DEPRECATED(message) __attribute__((deprecated(message)))
37#else
38# define LANCE_DEPRECATED(message)
39#endif
40
41/* Marks a result the caller must observe, such as a handle constructor or a
42 * borrowed lookup result. */
43#if defined(__cplusplus) && __cplusplus >= 201703L
44# define LANCE_NODISCARD [[nodiscard]]
45#elif defined(__GNUC__) || defined(__clang__)
46# define LANCE_NODISCARD __attribute__((warn_unused_result))
47#else
48# define LANCE_NODISCARD
49#endif
50
51#endif /* LANCE_ATTRIBUTES_H */