Affix

 view release on metacpan or  search on metacpan

infix/include/infix/infix.h  view on Meta::CPAN

#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__)

infix/src/common/compat_c23.h  view on Meta::CPAN

 * @details This header is a crucial component for maintaining source code
 * compatibility across a wide range of compilers that may not fully support the
 * latest C23 standard. It acts as a "shim" or compatibility layer, allowing the
 * rest of the codebase to be written using modern, standards-compliant syntax
 * while ensuring it still compiles on older C11/C17 compilers.
 *
 * The primary purpose is to define a set of `c23_*` macros (e.g., `c23_nodiscard`)
 * that translate modern C23 attribute syntax (`[[attribute]]`) into older,
 * compiler-specific equivalents (like `__attribute__((...))` for GCC/Clang or
 * `__declspec(...)` for MSVC). If a compiler supports none of these, the macros
 * expand to nothing, ensuring compilation succeeds at the cost of losing the
 * specific compiler check (a principle known as graceful degradation).
 *
 * This approach centralizes all compiler-specific feature detection, keeping the
 * rest of the library's code clean and free of `#ifdef` clutter.
 *
 * @internal
 */
#pragma once
#include "common/infix_config.h"
#include <infix/infix.h>

infix/src/common/compat_c23.h  view on Meta::CPAN

 */
#define c23_nodiscard INFIX_NODISCARD
/**
 * @def c23_deprecated
 * @brief A compatibility macro for the C23 `[[deprecated]]` attribute.
 *
 * @details This attribute is used to mark a function or type as obsolete. The
 * compiler will issue a warning if any code attempts to use a deprecated entity,
 * guiding users toward newer APIs and helping to manage API evolution.
 *
 * This macro expands to:
 * - `[[deprecated]]` on compilers that support the C23 standard syntax.
 * - `__attribute__((deprecated))` on GCC and Clang.
 * - `__declspec(deprecated)` on Microsoft Visual C++.
 * - Nothing on other compilers.
 */
#if COMPAT_HAS_C_ATTRIBUTE(deprecated)
#define c23_deprecated [[deprecated]]
#elif defined(INFIX_COMPILER_GCC) || defined(INFIX_COMPILER_CLANG)
#define c23_deprecated __attribute__((deprecated))
#elif defined(INFIX_COMPILER_MSVC)

infix/src/common/compat_c23.h  view on Meta::CPAN

#endif
/**
 * @def c23_fallthrough
 * @brief A compatibility macro for the C23 `[[fallthrough]]` attribute.
 *
 * @details This attribute is placed in a `switch` statement to explicitly indicate
 * that a `case` is intended to fall through to the next one. It suppresses
 * compiler warnings that would otherwise be generated for this pattern (e.g., `-Wimplicit-fallthrough`),
 * making the code's intent clearer.
 *
 * This macro expands to:
 * - `[[fallthrough]]` on compilers that support the C23 standard syntax.
 * - `__attribute__((fallthrough))` on GCC and Clang.
 * - Nothing on other compilers (including MSVC, which uses a different mechanism or lacks the warning).
 */
#if COMPAT_HAS_C_ATTRIBUTE(fallthrough)
#define c23_fallthrough [[fallthrough]]
#elif defined(INFIX_COMPILER_GCC) || defined(INFIX_COMPILER_CLANG)
#define c23_fallthrough __attribute__((fallthrough))
#else
#define c23_fallthrough
#endif
/**
 * @def c23_maybe_unused
 * @brief A compatibility macro for the C23 `[[maybe_unused]]` attribute.
 *
 * @details This attribute suppresses compiler warnings about unused variables,
 * parameters, or functions. It is useful for parameters that are only used in
 * certain build configurations (e.g., in an `#ifdef DEBUG` block) or for
 * functions that are part of a public API but not used internally.
 *
 * This macro expands to:
 * - `[[maybe_unused]]` on compilers that support the C23 standard syntax.
 * - `__attribute__((unused))` on GCC and Clang.
 * - Nothing on other compilers.
 */
#if COMPAT_HAS_C_ATTRIBUTE(maybe_unused)
#define c23_maybe_unused [[maybe_unused]]
#elif defined(INFIX_COMPILER_GCC) || defined(INFIX_COMPILER_CLANG)
#define c23_maybe_unused __attribute__((unused))
#else
#define c23_maybe_unused



( run in 0.567 second using v1.01-cache-2.11-cpan-97f6503c9c8 )