首页 > 其他 > 详细

C> gcc函数属性__nothrow__, __leaf__

时间:2021-04-22 23:53:14      阅读:27      评论:0      收藏:0      [点我收藏+]

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

C> gcc函数属性__nothrow__, __leaf__

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!