Can someone suggest a book or online reference I could print out that gets into the details of C99 (that's the version that microchip is based on =20 ??) that this thread and things like "ifndef" are covered. Microchip seems to leave out some=20 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= : > =20 >> Wouter van Ooijen wrote: >> =20 >>> > Afaict C varargs require the caller to do the removal >>> >>> =20 >>>> 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 have= a >>>> different interface for varargs and non-varargs functions. >>>> >>>> =20 >>> Maybe in super-ancient C, but with function prototypes... >>> >>> =20 >> But when the compiler builds the function it doesn't know whether the >> caller will be using function prototypes or not. >> =20 > 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 does > 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 th= e > types of the arguments after promotion are not compatible with the type= s > of the parameters, the behavior is undefined. > > So, if you try to call a vararg function without providing the prototype, > the result is undefined because you cannot define a vararg function > without using a prototype, see 6.9.1 p8. > > Daniel. > > =20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .