C> gcc函数属性__nothrow__, __leaf__

nothrow

__nothrow__属性告诉编译器函数不能抛出异常。

The nothrow attribute is used to inform the compiler that a function cannot
throw an exception. For example, most functions in the standard C library can
be guaranteed not to throw an exception with the notable exceptions of qsort
and bsearch that take function pointer arguments.

leaf

__leaf__属性表示不会调用其他任何函数。

-mtpcs-leaf-frame
Generate a stack frame that is compliant with the Thumb Procedure Call Stan-
dard for all leaf functions. (A leaf function is one that does not call any other
functions.) The default is ‘-mno-apcs-leaf-frame’.

noreturn

noreturn属性表示函数不能返回,少数标准库函数会用上如abort和exit(总是能执行成功,而且无需返回)。

A few standard library functions, such as abort and exit, cannot return. GCC
knows this automatically. Some programs define their own functions that never
return. You can declare them noreturn to tell the compiler this fact. For
example,
void fatal () __attribute__ ((noreturn));
void
fatal (/* . . . */)
{
/* . . . */ /* Print error message. */ /* . . . */
exit (1);
}
...

参考

Using the GNU Compiler Collection for GCC 10.2.0

原文链接: https://www.cnblogs.com/fortunely/p/14600343.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;

也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬

    C> gcc函数属性__nothrow__, __leaf__

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/403060

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年4月21日 上午11:20
下一篇 2023年4月21日 上午11:21

相关推荐