This MAY be of some use: http://www.greenend.org.uk/rjk/2003/03/inline.html & http://www.gnu.org/software/hello/manual/autoconf/Function-Portability.html On 13 August 2010 00:18, Carl Denk wrote: > Can someone suggest a book or online reference I could print out that get= s > into the details of C99 (that's the version that microchip is based on > ??) that this thread > and things like "ifndef" are covered. Microchip seems to leave out some > standard stuff, or I just haven't found where it's hiding. > > On 8/11/2010 11:13 PM, Daniel Serpell wrote: > > Hi, > > > > On Wed, Aug 11, 2010 at 5:54 PM, peter green > wrote: > > > >> Wouter van Ooijen wrote: > >> > >>> > Afaict C varargs require the caller to do the removal > >>> > >>> > >>>> because only the caller knows for sure how many parameters have been > >>>> passed and due to the retarted way C handles prototypes you can't ha= ve > a > >>>> different interface for varargs and non-varargs functions. > >>>> > >>>> > >>> Maybe in super-ancient C, but with function prototypes... > >>> > >>> > >> But when the compiler builds the function it doesn't know whether the > >> caller will be using function prototypes or not. > >> > > The C99 standard explicitly requires that you have the prototype in the > > varargs case, see 6.5.2.2 paragraph 6: > > > > If the expression that denotes the called function has a type that do= es > > not include a prototype, the integer promotions are performed on each > > argument, and arguments that have type float are promoted to double. > > These are called the default argument promotions. If the number of > > arguments does not agree with the number of parameters, the behavior = is > > undefined. If the function is defined with a type that includes a > > prototype, and either the prototype ends with an ellipsis (, ...) or > the > > types of the arguments after promotion are not compatible with the > types > > of the parameters, the behavior is undefined. > > > > So, if you try to call a vararg function without providing the prototyp= e, > > the result is undefined because you cannot define a vararg function > > without using a prototype, see 6.9.1 p8. > > > > Daniel. > > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .