当前位置:网站首页>Nonstandard compiler attribute extension
Nonstandard compiler attribute extension
2022-06-13 05:01:00 【Snow * sleet * snow】
As C Standard extension , Some compilers allow functions 、 Variables or types use some nonstandard properties . In brief, these macros are used for compiler optimization .GNU Compiler collection (GCC) and LLVM/Clang Use __attribute__ Syntax to specify these attributes . Different compilers may support different properties , It is also possible to use a completely different syntax .
NetBSD Code should generally avoid direct use __attribute__ Or some other similar syntax provided by a particular compiler .
however NetBSD The in <sys/cdefs.h> The following attribute macros are provided in the header file , These attribute macros can be automatically extended to the corresponding compiler syntax .
__dead
__pure
__constfunc
__noinline
__unused
__used
__diagused
__debugused
__packed
__aligned(x);
__section(section);
__read_mostly
__cacheline_aligned
__predict_true(exp);
__predict_false(exp);
__printflike(fmtarg, firstvararg);
__sysloglike(fmtarg, firstvararg);__dead
Certain functions, such as abort(3) and exit(3), can never return.
Some functions such as abort(3),exit(3), There is no return value . When used _dead When you declare a function , The compiler can do some optimization , Related warning May also be removed . Obviously with _dead Decorated functions except void No other types will be returned ._dead This is to tell the compiler that it can let go and optimize . similar __attribute__((noreturn)).
__pure
By __pure Modified function , Is defined as a function that has no effect other than the return value , The return value is assumed to depend only on function parameters and / Or global variables , For parameters and / Or global variables must also be read-only . If a function is to be correct volatile Variable ( Register variables, etc ) To read and write , Or access system resources that can be changed between successive calls , Can't use __pure Of . And __pure The equivalent function attribute is _attribute__((const))
__constfunc
__constfunc It's better than __pure More stringent variants , except __pure Beyond the limits of , The function it modifies can never access global variables , Nor can I get a pointer as a parameter . __constfunc The return value of the decorated function must only depend on the parameters passed by the value .
边栏推荐
- Kaggle time series tutorial
- Analysis on the similarities and differences of MVC, MVP and mvvc
- Article 49: understanding the behavior of new handler
- Interpretation of QT keypressevent
- Elliptic curve encryption
- Embedded hardware: electronic components (1) resistance capacitance inductance
- Luogu p1088 Martians
- lookup
- [JS solution] leedcode 200 Number of islands
- Luogu p1012 guess
猜你喜欢

Section 5 - Operator details

Search DFS and BFS

约瑟夫问题

How to lay copper in AD (aluminum designer)

Advanced C - Section 3 - character functions and string functions

详解OpenCV的函数cv::add(),并附各种情况的示例代码和运行结果

Brick story

C language exercise 1

自动评教脚本使用的配置
![C # get all callable methods of WebService interface [webmethod]](/img/44/4429b78c5b8341ed9a4a08d75a683e.png)
C # get all callable methods of WebService interface [webmethod]
随机推荐
Clause 31: avoid default capture mode
Shell built-in string substitution
Chapter 2 process management
QT client development -- driver loading problem of connecting to MySQL database
C language learning log 12.5
C language learning log 10.19
Keil uses j-link to burn the code, and an error occurs: Flash download failed - one of the "Cortex-M3" solutions
Configuration used by automatic teaching evaluation script
Analysis on the similarities and differences of MVC, MVP and mvvc
C language learning log 10.10
Force buckle 25 A group of K flipped linked lists
Infinite cycle scrolling code Alibaba international station store decoration code base map scrolling black translucent display effect custom content decoration code full screen display
Spice story
Article 29: assuming that the mobile operation does not exist, is expensive, and is not used
Clause 26: avoid overloading universal reference types
Handwritten promise and its method, with detailed notes
Bomb disposal cat
[leetcode]- binary search
Article 49: understanding the behavior of new handler
自动评教脚本使用的配置