美文网首页
extern "C"和函数异常的宏定义(c vs c++)

extern "C"和函数异常的宏定义(c vs c++)

作者: 小胖_20c7 | 来源:发表于2019-07-17 14:30 被阅读0次
这是libev中来自ev.h的一段宏定义
#ifdef __cplusplus
# define EV_CPP(x) x
# if __cplusplus >= 201103L
#  define EV_THROW noexcept
# else
#  define EV_THROW throw ()
# endif
#else
# define EV_CPP(x)
# define EV_THROW
#endif

EV_CPP(extern "C" {)
some c funcitons
EV_CPP(})
c++中函数定义中的throw():
告诉编译器,进行代码优化,不添加异常处理代码
在c++ 11中,被关键字noexcept代替

相关文章

网友评论

      本文标题:extern "C"和函数异常的宏定义(c vs c++)

      本文链接:https://www.haomeiwen.com/subject/kfsgkctx.html