Date: Thu, 16 May 1996 15:50:17 +0200 (IST) From: Eli Zaretskii To: Rainer Wank Cc: djgpp AT delorie DOT com, wank AT ftth DOT uebemc DOT siemens DOT de Subject: Re: vararg the second In-Reply-To: <9605100734.AA19401@malta> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 10 May 1996, Rainer Wank wrote: > 1.) You wrote, ELI ZARETSKII, that what i have done is forbidden in ANSI C. Sorry for the long delay, been quite busy lately. > What parts of my code are not ANSI conform ? > Where can i read that the parts of the code you will mention > are not ANSI conform ? The ANSI C standard says in para 7.8.1.1 ("The `va_start' macro"): void va_start (va_list ap, parmN); ... The parameter `parmN' is the identifier of the rightmost parameter in the variable parameter list in the function definition (the one just before the ", ..."). If the parameter `parmN' is declared with the `register' storage class, with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions, the behavior is undefined. ... And in para 7.8.1.2 it says: va_arg (va_list ap, ); ... ... if is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), the behavior is undefined. P.J. Plauger in his excellent "The Standard C Library" spells this in plain English (p. 209): You must not write a type T that widens when passed as an argument. Replace `float' with `double'. Replace `char', `signed char', `unsigned char', `short' and `unsigned short' with either `int' or `unsigned int'... > Why does the djgpp compiler does not warn me, even if have > used switches like -pedantic -ansi -Wall and so on ? I don't know how easy it is for a compiler to detect such problems. In any case, this should be reported to the appropriate GNU newsgroup, since DJGPP doesn't change the way the GNU C compiler works.