RE: variable arguments in ObjC
RE: variable arguments in ObjC
- Subject: RE: variable arguments in ObjC
- From: "Eric Ridge" <email@hidden>
- Date: Fri, 22 Feb 2002 12:34:44 -0500
- Thread-topic: variable arguments in ObjC
>
Now I've got this thing almost working, but I'm losing the
>
first argument.
>
Any ideas where it's gone?
The va_arg macro expands to an expression that has the type and value of
the _next_ argument in the call. Check the man page for va_arg.
>
>
[[Something alloc] initWith:@"one", @"two", @"three",
>
@"four", @"five",
>
nil]
>
>
- (id)initWith:(id)item, ...
>
{
>
va_list list;
>
va_start( list, item );
So, with your code, the "item" argument has the value of @"one". The
va_arg list starts at the next value (in this case @"two").
Typically, when using vaargs, the first argument to the method is a
format (a la xprintf), and the remaining arguments are the actual
values.
<snip>
>
va_list started
>
arg processed two
>
arg processed three
>
arg processed four
>
arg processed five
>
va_list ended
>
>
>
what happened to number 1?
again, @"one" is in the variable "item".
eric
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.