[LLVMdev] Seemingly ambiguous parameter lists

Robert Mykland robert at mykland.com
Tue Aug 26 20:32:01 PDT 2003

Dear Chris,

I had a second question which is probably a dumb question, but here 
goes.  I'm just wondering how a function that has all varargs knows what to 
do.  I'm only familiar with the C style of varargs.  In that case you 
generally used one or more fixed parameters that told you how to interpret 
the rest.  Like the format string in printf, for example.  I suppose the 
function could look at a static variable somewhere to get this data.  That 
sounds messy.  Are these functions member functions with an implied first 
parameter perhaps?  If so, why not explicitly?

-- Robert.

At 04:17 PM 8/26/2003 -0500, Chris Lattner wrote:
>On Tue, 26 Aug 2003, Robert Mykland wrote:
> > And while we're on the subject to the type definitions table, what's the
> > difference between
> >
> > 0e 07 01 00
> > function returning Int ( Void )?  Function returning Int ( ... )?
>Void is not a legal argument.  The bytecode file uses the void marker as
>a way to store the ... for a varargs function.  IE, the declaration:
>void foo(void);
>in C, becomes the LLVM type 'void ()*' %foo.  The C declaration:
>void foo(...);
>becomes the LLVM type 'void (...)*' %foo, which is stored in the bytecode
>file (to be compact) as 'void (void)*'.
> > 0e 07 00
> > Function returning Int ()
>That is just 'int ()', function returning int, with no arguments.
> > I'm guessing the former really is a function returning Int ( ... ), but how
> > is the callee supposed to decode the parameter list?  I'm an old callee and
> > I don't know this new trick.  :-)
>Void is not a legal argument type, it is just used as a marker in the
>bytecode files.  :)

Robert Mykland     Voice: (831) 462-6725 

More information about the llvm-dev mailing list