|
TR_datastructures 0.1.0
A generic C data structures library
|
Symbol visibility and compiler annotation macros. More...
Go to the source code of this file.
Macros | |
| #define | TR_EXPORT_SYMBOL |
| #define | TR_IMPORT_SYMBOL |
| #define | TR_LOCAL_SYMBOL |
| #define | TR_API |
| Marks a public API symbol for export or import. | |
| #define | TR_INTERNAL TR_LOCAL_SYMBOL |
| Marks a symbol as internal to the library. | |
| #define | TR_DEPRECATED(message) |
| Marks a public API function as deprecated. | |
| #define | TR_NODISCARD |
| Warns if the return value of a function is ignored. | |
Symbol visibility and compiler annotation macros.
Provides macros for controlling symbol visibility across platforms and build types. Supports MSVC, GCC, Clang and unknown compilers with graceful degradation.
The following macros are defined:
| #define TR_API |
Marks a public API symbol for export or import.
When building the library as a shared library:
__declspec(dllexport) when building the library (MSVC)__declspec(dllimport) when consuming the library (MSVC)__attribute__((visibility("default"))) on GCC/ClangWhen building as a static library expands to nothing.
Apply to all public API function declarations:
| #define TR_DEPRECATED | ( | message | ) |
Marks a public API function as deprecated.
Emits a compiler warning when the marked function is used, with a message explaining the deprecation.
__declspec(deprecated(message)) on MSVC__attribute__((deprecated(message))) on GCC/ClangExample usage:
| message | String literal describing the deprecation reason |
| #define TR_INTERNAL TR_LOCAL_SYMBOL |
Marks a symbol as internal to the library.
Prevents the symbol from being visible to consumers of the library even when building as a shared library.
__attribute__((visibility("hidden"))) on GCC/ClangApply to internal functions that must be visible across translation units within the library but not to consumers:
| #define TR_NODISCARD |
Warns if the return value of a function is ignored.
Apply to all functions returning tr_result_t to enforce error checking at the call site.
__attribute__((warn_unused_result)) on GCC/Clang_Check_return_ on MSVC 2012 and laterExample usage: