我要制作varargs
一次释放多个指针的函数,主要是为了清理代码。所以我有:
void free_all( ... ) {
va_list arguments;
/* Initializing arguments to store all values after last arg */
// but there are no args!
va_start ( arguments, ????? );
/* we expect the caller to send last argument as NULL **/
void* pointer = va_arg ( arguments, void* );
while( (pointer = va_arg ( arguments, void* ))!=NULL ) {
free(pointer);
}
va_end ( arguments ); // Cleans up the list
}
那么该放什么
va_start ( arguments, ????? )
?
最佳答案
这根本不可能。你必须有一个非可变参数,总是。在你的情况下
void free_all(void *first, ...);
可以工作。
关于c - 没有第一个参数的可变参数 - va_start 属于什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40846170/