mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-22 11:13:22 +00:00
new: 增加一些编译器相关的宏
This commit is contained in:
22
kernel/common/compiler_attributes.h
Normal file
22
kernel/common/compiler_attributes.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
// 当函数的返回值未被使用时,编译器抛出警告信息
|
||||
#define __must_check __attribute__((__warn_unused_result__))
|
||||
#define __force __attribute__((force))
|
||||
// 无返回值的属性
|
||||
#define __noreturn __attribute__((__noreturn__))
|
||||
/*
|
||||
* Optional: only supported since clang >= 14.0
|
||||
*
|
||||
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-error-function-attribute
|
||||
*/
|
||||
#if __has_attribute(__error__)
|
||||
#define __compiletime_error(msg) __attribute__((__error__(msg)))
|
||||
#else
|
||||
#define __compiletime_error(msg)
|
||||
#endif
|
||||
|
||||
typedef uint8_t __attribute__((__may_alias__)) __u8_alias_t;
|
||||
typedef uint16_t __attribute__((__may_alias__)) __u16_alias_t;
|
||||
typedef uint32_t __attribute__((__may_alias__)) __u32_alias_t;
|
||||
typedef uint64_t __attribute__((__may_alias__)) __u64_alias_t;
|
Reference in New Issue
Block a user