小编Kon*_*tei的帖子

C语言中的 throw 关键字是什么意思

我尝试用谷歌搜索它,但所有结果都是关于 C++ 的throw std::exception()

我正在阅读库(很好奇像printf,malloc和 之类的东西FILE是如何实现的)并发现了该malloc函数的定义:

extern void *malloc (size_t __size) __THROW __attribute_malloc__
     __attribute_alloc_size__ ((1)) __wur;
Run Code Online (Sandbox Code Playgroud)

当使用IDE(Visual Studio Code)追溯每个事物的定义时,__THROW导致了这样的情况:

# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
   // stuff that doesn't happen
# else
#  if defined __cplusplus && __GNUC_PREREQ (2,8)
#   define __THROW  throw ()
#   define __THROWNL    throw ()
#   define __NTH(fct)   __LEAF_ATTR fct throw ()
#   define __NTHNL(fct) fct throw ()
// continuation to the …
Run Code Online (Sandbox Code Playgroud)

c gcc keyword throw

0
推荐指数
1
解决办法
536
查看次数

标签 统计

c ×1

gcc ×1

keyword ×1

throw ×1