From: dontmailme AT iname DOT com (Steamer) Newsgroups: comp.os.msdos.djgpp Subject: Re: Library problem? Date: Sun, 23 Apr 2000 16:14:31 GMT Organization: always disorganized Lines: 23 Message-ID: <39032148.30016814@news.freeserve.net> References: <3900d15d DOT 7050493 AT news DOT telusplanet DOT net> <8dsbvo DOT 3vvpilr DOT 0 AT buerssner-17104 DOT user DOT cis DOT dfn DOT de> <39029b14 DOT 12321442 AT news DOT telusplanet DOT net> NNTP-Posting-Host: modem-80.blue-spotted-stingray.dialup.pol.co.uk X-Trace: news5.svr.pol.co.uk 956506472 25132 62.136.238.80 (23 Apr 2000 16:14:32 GMT) NNTP-Posting-Date: 23 Apr 2000 16:14:32 GMT X-Complaints-To: abuse AT theplanet DOT net 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 kalyniuk AT telusplanet DOT net wrote: >However, the only change I made was to >change the variable 'bore' from an int to a float. I would have >thought that the compiler or linker should have thrown up an error or >warning or something and that my program should have at least shown a >garbage value (I did use printf to debug) returned from the function >rather than just ignoring it and leaving it at zero. If I understand what you did correctly, here's what happened: Your prototype said that the function expected an int, when in fact it expected a float. You passed it a float in the interval (0,1). Since the compiler thought it was supposed to be an int it converted it to an int, namely 0 (since it rounds towards 0). No warning is given, because float-to-int conversion is entirely normal, specified by the ANSI standard, etc. (Note, however, that gcc _will_ warn you about such implicit conversion if you use the -Wconversion option.) The function was expecting a float, but a 0 int and a 0 float have exactly the same representation (four 0 bytes), so it interpreted the parameter as 0 anyway. S.