加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 我们可以在不调用va_start的情况下调用va_end吗?

发布时间:2020-12-16 09:45:50 所属栏目:百科 来源:网络整理
导读:如果我的理解是正确的,va_end被调用以进行清理并且在相同的上下文中,va_end的手册页说 va_end() Each invocation of va_start() must be matched by a corresponding invocation of va_end() in the same function. After the call va_end(ap) the variable
如果我的理解是正确的,va_end被调用以进行清理并且在相同的上下文中,va_end的手册页说

va_end()

Each invocation of va_start() must be matched by a corresponding
invocation of va_end() in the same function. After the call va_end(ap)
the variable ap is undefined. Multiple traversals of the list,each
bracketed by va_start() and va_end() are possible. va_end() may be a
macro or a function.

因此,如果调用va_start,则显然需要调用va_end,但是反向关系是否成立,即va_end是否应始终以va_start开头?

解决方法

从C99 7.15.1.3/2“va_end宏”:

If there is no corresponding invocation of the va_start or va_copy macro,or if the va_end macro is not invoked before the return,the behavior is unde?ned.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读