// Copyright 2023 alexevier // licensed under the zlib license #ifndef lexlib_common_h #define lexlib_common_h /* this header is not documented since its not suposed to be used externally of lexlib and any changes may break api */ #include"defines.h" #ifdef __cplusplus # define LEXLIB_RESTRICT # define LEXLIB_EXTERN extern "C" #else # define LEXLIB_RESTRICT restrict # define LEXLIB_EXTERN extern #endif #ifdef __GNUC__ # define LEXLIB_INLINE static inline __attribute__((always_inline)) # define LEXLIB_DEPRECATED __attribute__((deprecated)) # define LEXLIB_FALLTHROUGH __attribute__((fallthrough)) # define LEXLIB_ALIGN(X) __attribute__((aligned(X))) # define LEXLIB_UNUSED __attribute__((unused)) #else # define LEXLIB_INLINE static inline # define LEXLIB_DEPRECATED # define LEXLIB_FALLTHROUGH # define LEXLIB_ALIGN(X) # define LEXLIB_UNUSED #endif #ifdef __BYTE_ORDER__ # if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ # define LEXLIB_LITTLE_ENDIAN LEXLIB_FALSE # define LEXLIB_BIG_ENDIAN LEXLIB_TRUE # else /* if its not big endian or can't be detected fallback to little endian. */ # define LEXLIB_LITTLE_ENDIAN LEXLIB_TRUE # define LEXLIB_BIG_ENDIAN LEXLIB_FALSE # endif #else # warning lexlib could not detected endianness, __BYTE_ORDER__ not defined, fallback to little # define LEXLIB_LITTLE_ENDIAN LEXLIB_TRUE # define LEXLIB_BIG_ENDIAN LEXLIB_FALSE #endif #define LEXLIB_BUFFER_SIZE 256 #endif