From: horst DOT kraemer AT gmx DOT de (Horst Kraemer) Newsgroups: comp.os.msdos.djgpp Subject: Re: Conversion warnings Date: Thu, 10 Aug 2000 06:34:55 GMT Lines: 55 Message-ID: <39924ada.89663228@news.cis.dfn.de> References: <200008092306 DOT TAA18952 AT websmtp1 DOT bellsouth DOT bigfoot DOT com> NNTP-Posting-Host: a1036.pppool.de (213.6.16.54) X-Trace: fu-berlin.de 965889236 7805934 213.6.16.54 (16 [27606]) X-Newsreader: Forte Free Agent 1.11/32.235 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Wed, 09 Aug 2000 19:19:02 -0400, "Lets Go Canes!" wrote: > While compiling a program, I am getting some strange > conversion warnings - I have -Wconversion enabled > intentionally to catch unintended conversions. > > The following short sample will demonstrate: > > ---------- > void f(float, char); > > int main(void) > { > float x; > char c; > > x = 22.0 / 7.0; > c = '*'; > > f(x, c); > return 1; > > } > ---------- > > When compiled, it gives the following output: > > gcc -Wconversion -c test.c > test.c: In function `main': > test.c:11: warning: passing arg 1 of `f' as `float' rather than `double' due to prototype > test.c:11: warning: passing arg 2 of `f' with different width due to prototype > Any ideas? The problem is that -Wconversion doesn't do what you think it does. Please read the documentation. It says that -Wconversions warns if the handling of the parameter would be different for a function *without* prototype. Thus, if you would pass your arguments to a function declared as void ff(); then for ff(x,c) the first parameter 'x' would be converted to double and the second parameter 'c' would be converted to 'int'. As you have a prototyped function f and x,c exactly match the definition of the prototype for f the handling of the parameters is *different* from the handling for the call of ff. This is probably not useful for your purpose but that's how it is defined. Regards Horst