Deutsch English Français Italiano |
<868qt4qn92.fsf@linuxsc.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch <tr.17687@z991.linuxsc.com> Newsgroups: comp.lang.c Subject: Re: question about linker Date: Wed, 27 Nov 2024 15:18:33 -0800 Organization: A noiseless patient Spider Lines: 50 Message-ID: <868qt4qn92.fsf@linuxsc.com> References: <vi54e9$3ie0o$1@dont-email.me> <vi56hi$3ie0o$2@dont-email.me> <vi57bh$3ip1o$2@dont-email.me> <vi58ba$3ie0o$4@dont-email.me> <20241127123616.00003269@yahoo.com> <vi6uji$3ve13$3@dont-email.me> <20241127150139.0000702c@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Thu, 28 Nov 2024 00:18:36 +0100 (CET) Injection-Info: dont-email.me; posting-host="8f1c290f3ddf609884269e518a4a547d"; logging-data="237916"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19f0X+aXQv6VxxXtuzKaOWS3xxatWQko1M=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:J3UEIX/ytszpLq6FtE2OhUhyReY= sha1:/z/A4IeCkZ8Y6BWAP7n5sx50yZE= Bytes: 2978 Michael S <already5chosen@yahoo.com> writes: > On Wed, 27 Nov 2024 08:08:34 -0300 > Thiago Adams <thiago.adams@gmail.com> wrote: > >> Without function prototypes, the compiler will use the types it >> has on the caller's side, possibly with integer promotions. >> >> Calling a function with a double will assume the function is >> implemented receiving a double. >> The function implementation will need to match these types. >> >> With function prototypes, we can call a f(int i) with f(1.1) and >> then the caller side will convert before calling f. > > Yes. With one more complication that there was floating-point > promotion as well as integer promotion. IIRC, before they > invented prototypes it was impossible to write functions with > 'float' parameters. I believe the last statement there isn't exactly right. If we have a K&R-style function definition, as for example int not_too_small( f ) float f; { return f > 1.e-250; } that declares a parameter 'f' with type float, then as far as the body of the function is concerned the type of 'f' is float. It is of course true that, as far as callers are concerned, the function expects a double argument, but that isn't the same as a double parameter. Consider this similar function: int not_too_small_two( f ) double f; { return f > 1.e-250; } These two function do not have the same behavior. The reason for that difference is that in one case any argument value is left as is (as a double), and is treated as such, and in the other case any argument value is converted (inside the function body) from a double to a float, and is treated within the function body as a float object, not as a double object. (Calling with 1.e-200 as an argument should show one case of different behaviors.)