Affix
view release on metacpan or search on metacpan
infix/include/infix/infix.h view on Meta::CPAN
*
* // Call the function through the FFI interface.
* cif(&result, args);
*
* printf("Result: %d\n", result); // Output: Result: 42
*
* infix_forward_destroy(trampoline);
* return 0;
* }
* ```
*/
#pragma once
/**
* @defgroup version_info Version Information
* @brief Macros defining the semantic version of the infix library.
* @details The versioning scheme follows Semantic Versioning 2.0.0 (SemVer).
* @{
*/
#define INFIX_MAJOR 0 /**< The major version number. Changes with incompatible API updates. */
#define INFIX_MINOR 1 /**< The minor version number. Changes with new, backward-compatible features. */
#define INFIX_PATCH 6 /**< The patch version number. Changes with backward-compatible bug fixes. */
#if defined(__has_c_attribute)
#define _INFIX_HAS_C_ATTRIBUTE(x) __has_c_attribute(x)
#else
#define _INFIX_HAS_C_ATTRIBUTE(x) 0
#endif
/**
* @def INFIX_API
* @brief Symbol visibility macro
*
* @details infix relies on a unity build so we've been lax about symbol visibility. Functions like `_infix_set_error`
* or `_infix_type_recalculate_layout` are shared between internal modules (files included by `infix.c`) and thus cannot
* be static. However, this means that if infix.c is compiled into a shared library (`libinfix.so`), all of these
* internal _infix_* functions are exported in the dynamic symbol table. This pollutes the ABI and allows users to link
* against internal functions that might change.
*/
#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(INFIX_BUILDING_DLL)
#define INFIX_API __declspec(dllexport)
#elif defined(INFIX_USING_DLL)
#define INFIX_API __declspec(dllimport)
#else
#define INFIX_API
#endif
#elif defined(__GNUC__) || defined(__clang__)
#define INFIX_API __attribute__((visibility("default")))
#else
#define INFIX_API
#endif
/**
* @def INFIX_NODISCARD
* @brief A compatibility macro for the C23 `[[nodiscard]]` attribute.
*
* @details This attribute is used to issue a compiler warning if the return value
* of a function is ignored by the caller. This is extremely useful for catching
* bugs where an error code or an important result is not checked.
*
* This macro expands to:
* - `[[nodiscard]]` on compilers that support the C23 standard syntax.
* - `__attribute__((warn_unused_result))` on GCC and Clang.
* - `_Check_return_` on Microsoft Visual C++.
* - Nothing on other compilers.
*
* This is aliased as `c23_nodiscard` in `compat_c23.h`.
*/
#if _INFIX_HAS_C_ATTRIBUTE(nodiscard) && !defined(__GNUC__) && !defined(__clang__)
#define INFIX_NODISCARD [[nodiscard]]
#elif defined(__GNUC__) || defined(__clang__)
#define INFIX_NODISCARD __attribute__((warn_unused_result))
#elif defined(_MSC_VER)
#define INFIX_NODISCARD _Check_return_
#else
#define INFIX_NODISCARD
#endif
/**
* @struct infix_version_t
* @brief A structure representing the semantic version of the library.
* @see infix_get_version
*/
typedef struct {
int major; /**< The major version number (incremented for incompatible API changes). */
int minor; /**< The minor version number (incremented for backwards-compatible features). */
int patch; /**< The patch version number (incremented for backwards-compatible bug fixes). */
} infix_version_t;
/** @} */
// Define the POSIX source macro to ensure function declarations for shm_open,
// ftruncate, etc., are visible on all POSIX-compliant systems.
// This must be defined before any system headers are included.
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
// Define the POSIX source macro to ensure function declarations for posix_memalign
// are visible. This must be defined before any system headers are included.
#if !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200809L
#endif
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Retrieves the version of the infix library linked at runtime.
*
* @details This function allows applications to verify that the version of the
* library they are linked against matches the headers they were compiled with.
* This is particularly useful when loading `infix` as a shared library/DLL
* to detect version mismatches.
*
* @return An `infix_version_t` structure containing the major, minor, and patch numbers.
*/
INFIX_API INFIX_NODISCARD infix_version_t infix_get_version(void);
/**
( run in 1.987 second using v1.01-cache-2.11-cpan-97f6503c9c8 )