TRLC Platform Library  1.0.0
Header-only C++ library for compile-time platform detection and abstraction
macros.hpp File Reference

Portable cross-platform macros for common C++ idioms and optimizations. More...

Go to the source code of this file.

Namespaces

 trlc
 
 trlc::platform
 

Macros

#define TRLC_HAS_CPP_ATTRIBUTE(x)   0
 Check if __has_cpp_attribute is available. More...
 
#define TRLC_HAS_BUILTIN(x)   0
 Check if __has_builtin is available. More...
 
#define TRLC_NODISCARD
 
#define TRLC_DEPRECATED
 
#define TRLC_DEPRECATED_MSG(msg)   TRLC_DEPRECATED
 
#define TRLC_FALLTHROUGH   ((void)0)
 
#define TRLC_MAYBE_UNUSED
 
#define TRLC_FORCE_INLINE   inline
 
#define TRLC_NEVER_INLINE
 
#define TRLC_INLINE   inline
 
#define TRLC_LIKELY(x)   (x)
 
#define TRLC_UNLIKELY(x)   (x)
 
#define TRLC_NOEXCEPT
 
#define TRLC_HAS_EXCEPTIONS_ENABLED   0
 
#define TRLC_NOEXCEPT_IF(cond)
 
#define TRLC_API_EXPORT
 
#define TRLC_API_IMPORT
 
#define TRLC_API_HIDDEN
 
#define TRLC_API   TRLC_API_IMPORT
 
#define TRLC_HAS_CPP17   1
 C++17 feature detection. More...
 
#define TRLC_RESTRICT
 
#define TRLC_PACKED
 
#define TRLC_PACK_BEGIN
 
#define TRLC_PACK_END
 
#define TRLC_ALIGNED(bytes)
 
#define TRLC_CACHE_ALIGNED   TRLC_ALIGNED(64)
 
#define TRLC_DIAGNOSTIC_PUSH
 
#define TRLC_DIAGNOSTIC_POP
 
#define TRLC_DIAGNOSTIC_IGNORE_UNUSED_PARAMETER
 
#define TRLC_DIAGNOSTIC_IGNORE_UNUSED_VARIABLE
 
#define TRLC_DIAGNOSTIC_IGNORE_UNUSED_FUNCTION
 
#define TRLC_IF(condition, code)
 
#define TRLC_IF_ELSE(condition, then_code, else_code)
 
#define TRLC_USE(var)   ((void)(var))
 
#define TRLC_UNREACHABLE()   ((void)0)
 
#define TRLC_STRINGIFY(x)   #x
 
#define TRLC_STRINGIFY_EXPANDED(x)   TRLC_STRINGIFY(x)
 
#define TRLC_CONCAT(a, b)   a##b
 
#define TRLC_CONCAT_EXPANDED(a, b)   TRLC_CONCAT(a, b)
 
#define TRLC_FEATURE_AVAILABLE(feature)   (TRLC_HAS_##feature)
 
#define TRLC_ON_WINDOWS(code)
 
#define TRLC_ON_POSIX(code)
 
#define TRLC_PLATFORM_WINDOWS   0
 
#define TRLC_PLATFORM_POSIX   0
 
#define TRLC_ON_X86_64(code)
 
#define TRLC_ARCH_X86_64   0
 
#define TRLC_ON_ARM64(code)
 
#define TRLC_ARCH_ARM64   0
 
#define TRLC_MACROS_VERSION_MAJOR   1
 Macro version information. More...
 
#define TRLC_MACROS_VERSION_MINOR   0
 
#define TRLC_MACROS_VERSION_PATCH   0
 
#define TRLC_MACROS_VERSION_STRING   "1.0.0"
 
#define TRLC_MACROS_VERSION_AT_LEAST(major, minor, patch)
 
#define TRLC_MACROS_INCLUDED
 

Functions

static bool trlc::platform::supportsNodecard ()
 Check if compiler supports nodiscard attribute. More...
 
static bool trlc::platform::supportsDeprecated ()
 Check if compiler supports deprecated attribute. More...
 
static bool trlc::platform::supportsFallthrough ()
 Check if compiler supports fallthrough attribute. More...
 
static bool trlc::platform::hasAttributeSupport (const char *)
 Check if compiler supports a specific C++ attribute. More...
 

Detailed Description

Portable cross-platform macros for common C++ idioms and optimizations.

This header provides a comprehensive set of portable macros that abstract compiler-specific features and attributes. All macros gracefully degrade on unsupported compilers while maintaining compatibility.

Features:

  • Portable C++ attributes (nodiscard, deprecated, fallthrough)
  • Inlining control (force inline, never inline)
  • Branch prediction hints (likely/unlikely)
  • Exception safety annotations
  • Symbol visibility control for shared libraries
  • Utility macros for conditional compilation
Author
TRLC Platform Team
Version
1.0.0

Definition in file macros.hpp.

Macro Definition Documentation

◆ TRLC_ALIGNED

#define TRLC_ALIGNED (   bytes)

Definition at line 597 of file macros.hpp.

◆ TRLC_API

#define TRLC_API   TRLC_API_IMPORT

Definition at line 481 of file macros.hpp.

◆ TRLC_API_EXPORT

#define TRLC_API_EXPORT

Definition at line 419 of file macros.hpp.

◆ TRLC_API_HIDDEN

#define TRLC_API_HIDDEN

Definition at line 461 of file macros.hpp.

◆ TRLC_API_IMPORT

#define TRLC_API_IMPORT

Definition at line 440 of file macros.hpp.

◆ TRLC_ARCH_ARM64

#define TRLC_ARCH_ARM64   0

Definition at line 851 of file macros.hpp.

◆ TRLC_ARCH_X86_64

#define TRLC_ARCH_X86_64   0

Definition at line 843 of file macros.hpp.

◆ TRLC_CACHE_ALIGNED

#define TRLC_CACHE_ALIGNED   TRLC_ALIGNED(64)

Definition at line 610 of file macros.hpp.

◆ TRLC_CONCAT

#define TRLC_CONCAT (   a,
 
)    a##b

Definition at line 760 of file macros.hpp.

◆ TRLC_CONCAT_EXPANDED

#define TRLC_CONCAT_EXPANDED (   a,
 
)    TRLC_CONCAT(a, b)

Definition at line 761 of file macros.hpp.

◆ TRLC_DEPRECATED

#define TRLC_DEPRECATED

Definition at line 158 of file macros.hpp.

◆ TRLC_DEPRECATED_MSG

#define TRLC_DEPRECATED_MSG (   msg)    TRLC_DEPRECATED

Definition at line 182 of file macros.hpp.

◆ TRLC_DIAGNOSTIC_IGNORE_UNUSED_FUNCTION

#define TRLC_DIAGNOSTIC_IGNORE_UNUSED_FUNCTION

Definition at line 646 of file macros.hpp.

◆ TRLC_DIAGNOSTIC_IGNORE_UNUSED_PARAMETER

#define TRLC_DIAGNOSTIC_IGNORE_UNUSED_PARAMETER

Definition at line 644 of file macros.hpp.

◆ TRLC_DIAGNOSTIC_IGNORE_UNUSED_VARIABLE

#define TRLC_DIAGNOSTIC_IGNORE_UNUSED_VARIABLE

Definition at line 645 of file macros.hpp.

◆ TRLC_DIAGNOSTIC_POP

#define TRLC_DIAGNOSTIC_POP

Definition at line 643 of file macros.hpp.

◆ TRLC_DIAGNOSTIC_PUSH

#define TRLC_DIAGNOSTIC_PUSH

Definition at line 642 of file macros.hpp.

◆ TRLC_FALLTHROUGH

#define TRLC_FALLTHROUGH   ((void)0)

Definition at line 212 of file macros.hpp.

◆ TRLC_FEATURE_AVAILABLE

#define TRLC_FEATURE_AVAILABLE (   feature)    (TRLC_HAS_##feature)

Definition at line 784 of file macros.hpp.

◆ TRLC_FORCE_INLINE

#define TRLC_FORCE_INLINE   inline

Definition at line 259 of file macros.hpp.

◆ TRLC_HAS_BUILTIN

#define TRLC_HAS_BUILTIN (   x)    0

Check if __has_builtin is available.

This macro provides a safe way to check for compiler builtin support. Returns 0 if __has_builtin is not available.

Definition at line 108 of file macros.hpp.

◆ TRLC_HAS_CPP17

#define TRLC_HAS_CPP17   1

C++17 feature detection.

Detects if C++17 features are available. Works independently from cpp_standard.hpp for macros-only usage.

Definition at line 495 of file macros.hpp.

◆ TRLC_HAS_CPP_ATTRIBUTE

#define TRLC_HAS_CPP_ATTRIBUTE (   x)    0

Check if __has_cpp_attribute is available.

This macro provides a safe way to check for C++ attribute support. Returns 0 if __has_cpp_attribute is not available. Note: MSVC doesn't support __has_cpp_attribute in C++17 mode.

Definition at line 96 of file macros.hpp.

◆ TRLC_HAS_EXCEPTIONS_ENABLED

#define TRLC_HAS_EXCEPTIONS_ENABLED   0

Definition at line 367 of file macros.hpp.

◆ TRLC_IF

#define TRLC_IF (   condition,
  code 
)
Value:
do { \
if constexpr (condition) { \
code; \
} \
} while (0)

Definition at line 668 of file macros.hpp.

◆ TRLC_IF_ELSE

#define TRLC_IF_ELSE (   condition,
  then_code,
  else_code 
)
Value:
do { \
if constexpr (condition) { \
then_code; \
} else { \
else_code; \
} \
} while (0)

Definition at line 692 of file macros.hpp.

◆ TRLC_INLINE

#define TRLC_INLINE   inline

Definition at line 293 of file macros.hpp.

◆ TRLC_LIKELY

#define TRLC_LIKELY (   x)    (x)

Definition at line 320 of file macros.hpp.

◆ TRLC_MACROS_INCLUDED

#define TRLC_MACROS_INCLUDED

Definition at line 889 of file macros.hpp.

◆ TRLC_MACROS_VERSION_AT_LEAST

#define TRLC_MACROS_VERSION_AT_LEAST (   major,
  minor,
  patch 
)
Value:
((TRLC_MACROS_VERSION_MAJOR > (major)) || \
#define TRLC_MACROS_VERSION_MAJOR
Macro version information.
Definition: macros.hpp:863
#define TRLC_MACROS_VERSION_PATCH
Definition: macros.hpp:865
#define TRLC_MACROS_VERSION_MINOR
Definition: macros.hpp:864

Definition at line 882 of file macros.hpp.

◆ TRLC_MACROS_VERSION_MAJOR

#define TRLC_MACROS_VERSION_MAJOR   1

Macro version information.

Allows other components to check the version of the macros module.

Definition at line 863 of file macros.hpp.

◆ TRLC_MACROS_VERSION_MINOR

#define TRLC_MACROS_VERSION_MINOR   0

Definition at line 864 of file macros.hpp.

◆ TRLC_MACROS_VERSION_PATCH

#define TRLC_MACROS_VERSION_PATCH   0

Definition at line 865 of file macros.hpp.

◆ TRLC_MACROS_VERSION_STRING

#define TRLC_MACROS_VERSION_STRING   "1.0.0"

Definition at line 866 of file macros.hpp.

◆ TRLC_MAYBE_UNUSED

#define TRLC_MAYBE_UNUSED

Definition at line 234 of file macros.hpp.

◆ TRLC_NEVER_INLINE

#define TRLC_NEVER_INLINE

Definition at line 280 of file macros.hpp.

◆ TRLC_NODISCARD

#define TRLC_NODISCARD

◆ TRLC_NOEXCEPT

#define TRLC_NOEXCEPT

Definition at line 366 of file macros.hpp.

◆ TRLC_NOEXCEPT_IF

#define TRLC_NOEXCEPT_IF (   cond)

Definition at line 391 of file macros.hpp.

◆ TRLC_ON_ARM64

#define TRLC_ON_ARM64 (   code)

Definition at line 850 of file macros.hpp.

◆ TRLC_ON_POSIX

#define TRLC_ON_POSIX (   code)

Definition at line 815 of file macros.hpp.

◆ TRLC_ON_WINDOWS

#define TRLC_ON_WINDOWS (   code)

Definition at line 814 of file macros.hpp.

◆ TRLC_ON_X86_64

#define TRLC_ON_X86_64 (   code)

Definition at line 842 of file macros.hpp.

◆ TRLC_PACK_BEGIN

#define TRLC_PACK_BEGIN

Definition at line 569 of file macros.hpp.

◆ TRLC_PACK_END

#define TRLC_PACK_END

Definition at line 570 of file macros.hpp.

◆ TRLC_PACKED

#define TRLC_PACKED

Definition at line 568 of file macros.hpp.

◆ TRLC_PLATFORM_POSIX

#define TRLC_PLATFORM_POSIX   0

Definition at line 817 of file macros.hpp.

◆ TRLC_PLATFORM_WINDOWS

#define TRLC_PLATFORM_WINDOWS   0

Definition at line 816 of file macros.hpp.

◆ TRLC_RESTRICT

#define TRLC_RESTRICT

Definition at line 544 of file macros.hpp.

◆ TRLC_STRINGIFY

#define TRLC_STRINGIFY (   x)    #x

Definition at line 758 of file macros.hpp.

◆ TRLC_STRINGIFY_EXPANDED

#define TRLC_STRINGIFY_EXPANDED (   x)    TRLC_STRINGIFY(x)

Definition at line 759 of file macros.hpp.

◆ TRLC_UNLIKELY

#define TRLC_UNLIKELY (   x)    (x)

Definition at line 344 of file macros.hpp.

◆ TRLC_UNREACHABLE

#define TRLC_UNREACHABLE ( )    ((void)0)

Definition at line 744 of file macros.hpp.

◆ TRLC_USE

#define TRLC_USE (   var)    ((void)(var))

Definition at line 722 of file macros.hpp.