为什么 FLexeLint 在下面的代码中抛出错误“警告 530:符号‘va’(第 23 行)未初始化”。
void debug(int msglevel, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
vfprintf(stderr, fmt, va);
va_end(va);
}
是否需要初始化va_list?
最佳答案
没有必要。来自man page for stdarg :
void va_start(va_list ap, last);
The
va_start()
macro initializes ap for subsequent use byva_arg()
andva_end()
, and must be called first.
此外,来自 C standard 的第 7.16.1.4 节:
2 The
va_start
macro shall be invoked before any access to the unnamed arguments.3 The
va_start
macro initializesap
for subsequent use by theva_arg
andva_end
macros. Neither theva_start
norva_copy
macro shall be invoked to reinitializeap
without an intervening invocation of theva_end
macro for the sameap
.
关于c - FlexeLint 在 va_list 上抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43832540/