Is it possible to create a C varargs function with no arguments? [duplicate]

匿名 (未验证) 提交于 2019-12-03 01:03:01

问题:

Possible Duplicate:
Is it possible to have a variadic function in C with no non-variadic parameter?

Is it possible to create a C varargs function with no arguments?

For example:

int foo(...); 

I want to do something like the following:

list* create_list(...){     list *mylist = list_create();     void *current_arg = va_arg(void*);     while (current_arg != NULL){         list_add(mylist, current_arg);         current_arg = va_arg(void*);     }     return mylist; } 

回答1:

No. Variadic functions must have one or more named parameters.

Try it yourself, you'll see something like:

error: ISO C requires a named argument before '...'



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!