C CASTLE / MODULE NOTES
CASTLE/Modules/Core

MODULE 06 / 15

Compiler abstraction

Centralized compiler detection, attribute wrappers, and portability macros keep the rest of Castle toolchain-neutral.

#include "castle/core/compiler.hpp"

Overview

Castle's compiler abstraction layer centralizes compiler detection, standard attribute wrappers, and keyword-style portability macros so the rest of the library can stay toolchain-neutral.

Dependencies

  • Compiler variants: clang.md, arm.md, gcc.md, default.md

Public API

APIDescription
CASTLE_UNUSED, CASTLE_NODISCARD, CASTLE_FALL_THROUGH, CASTLE_DEPRECATED, CASTLE_DEPRECATED_MSG(x)Wrap standard C++17 attributes behind Castle names.
CASTLE_VOLATILE, CASTLE_MUTABLE, CASTLE_CONST, CASTLE_CONSTEXPR, CASTLE_IF_CONSTEXPR, CASTLE_NOEXCEPTWrap core C++ qualifiers and statements used throughout Castle.
CASTLE_DEFAULT, CASTLE_DELETE, CASTLE_OVERRIDE, CASTLE_FINAL, CASTLE_VIRTUALWrap special-member and inheritance keywords.
CASTLE_MOVE, CASTLE_FORWARD, CASTLE_STDName Castle forwarding helpers or the std namespace without spelling them directly.
Backend selectionIncludes one compiler-variant header according to the active compiler.

Usage example

See samples/sample_compiler.cpp.

#include "castle/core/compiler.hpp"

CASTLE_NODISCARD CASTLE_CONSTEXPR int answer() CASTLE_NOEXCEPT
{
    return 42;
}

Constraints & notes

  • Intended as a low-level dependency used transitively by most Castle headers.
  • Performs compile-time selection only; there is no runtime state or allocation.
  • CASTLE_MOVE and CASTLE_FORWARD refer to Castle utilities and are only useful once those helpers are available.