7

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;
}
Community
  • 1
  • 1
chacham15
  • 13,719
  • 26
  • 104
  • 207
  • There is already a valid answer concerning functions. In the contrast to that, vaarg *macros* with only `...` are allowed. So if you'd tell us what you want to achieve, there might be a way ... – Jens Gustedt Aug 04 '12 at 20:40
  • 1
    You can fake it with a dummy argument and a variadic macro that hides the need for the dummy argument. – R.. GitHub STOP HELPING ICE Aug 04 '12 at 20:44

1 Answers1

8

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

pb2q
  • 58,613
  • 19
  • 146
  • 147