sta-core/include/sta/lang.hpp
2022-04-15 14:58:24 +02:00

50 lines
1.0 KiB
C++

/**
* @brief Helper for useful compiler features.
*/
#ifndef STA_LANG_HPP
#define STA_LANG_HPP
#ifndef STA_ASM
# define STA_ASM __asm
#endif // STA_ASM
#ifndef STA_DEPRECATED
# define STA_DEPRECATED __attribute__((deprecated))
#endif // STA_DEPRECATED
#ifndef STA_WEAK
# define STA_WEAK __attribute__((weak))
#endif // STA_WEAK
#ifndef STA_PACKED
# define STA_PACKED __attribute__((packed))
#endif // STA_PACKED
#ifndef STA_PACKED_STRUCT
# define STA_PACKED_STRUCT struct STA_PACKED
#endif // STA_PACKED_STRUCT
#ifndef STA_PACKED_UNION
# define STA_PACKED_UNION union STA_PACKED
#endif // STA_PACKED_UNION
#ifndef STA_BKPT
# define STA_BKPT(value) STA_ASM volatile ("bkpt "#value)
#endif // STA_BKPT
// TODO Check for GCC
/**
* @brief Helper for silencing compiler warnings in unreachable code locations.
*
* Example: Default of switch handling all cases of enum class
*/
#ifndef STA_UNREACHABLE
# define STA_UNREACHABLE() __builtin_unreachable()
#endif // STA_UNREACHABLE
#endif // STA_LANG_HPP