Variable arg function question
Patrick Clochesy
pcloches at gmail.com
Sun May 4 14:02:50 UTC 2008
What about using a macro (...) in front of the function to csll it
which passes __VARARGS__, NULL to ensure there is always a trailing
NULL? I think this would at least work in GCC... Can' test on my phone
though.
-Patrick
On May 4, 2008, at 4:42 AM, Peter Boosten <peter at boosten.org> wrote:
> Unga wrote:
>> Hi all
>> I need to implement a variable argument function in C.
>> The number of args are not known but the type is
>> known, all are strings.
>> Unfortunately va_arg() [stdarg(3)] does not return
>> NULL or any other suitable value after processing the
>> arg list, it just simply crashes once the arg list is
>> exhausted.
>> It seems there is no way to know the number of args
>> inside the called function.
>
> Why is it in your opinion so hard to count the number of arguments
> *before* you call the function, in other words, what in your program
> prevents this count?
>
> Peter
> --
> http://www.boosten.org
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org
> "
More information about the freebsd-questions
mailing list