Skip to content

Dealing with va_list arguments

Nat! edited this page Mar 12, 2017 · 1 revision

To keep code working on all runtimes, rewrite:

+ (EOQualifier *) qualifierWithQualifierFormat:(NSString *) format, ...
{
   EOQualifier   *obj;
   va_list       ap;
      
   va_start( ap, format);
   obj = [self qualifierWithQualifierFormat:format
                                 varargList:ap];
   va_end( ap);

   return( obj);
}

as

+ (EOQualifier *) qualifierWithQualifierFormat:(NSString *) format, ...
{
   EOQualifier   *obj;

#ifdef __MULLE_OBJC__
   {
      mulle_vararg_list   args;

      mulle_vararg_start( args, format);
      obj = [self qualifierWithQualifierFormat:format
                                     arguments:args];
      mulle_vararg_end( args);
   }
#else
   {
      va_list   ap;
      
      va_start( ap, format);
      obj = [self qualifierWithQualifierFormat:format
                                    varargList:ap];
      va_end( ap);
   }
#endif
   
   return( obj);
}

The convention is to use varargList: for va_list and arguments: for mulle_vararg_list. You then need have two methods, one dealing with va_list and the other with mulle_vararg_list arguments.