Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

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;
}
like image 526
chacham15 Avatar asked Aug 04 '12 20:08

chacham15


1 Answers

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 '...'

like image 174
pb2q Avatar answered Sep 28 '22 14:09

pb2q