Deutsch English Français Italiano |
<vi7csp$25vc$2@dont-email.me> 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: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c Subject: Re: question about linker Date: Wed, 27 Nov 2024 16:12:25 +0100 Organization: A noiseless patient Spider Lines: 56 Message-ID: <vi7csp$25vc$2@dont-email.me> 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=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 27 Nov 2024 16:12:25 +0100 (CET) Injection-Info: dont-email.me; posting-host="487d0a8059509a11a02f0c3a682b1a92"; logging-data="71660"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zGzQM1+JvY8luRcqJSEu8vxarA4hD3q0=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:aMoqYmYql0+AvzJWNJx5tUHeOrc= In-Reply-To: <20241127150139.0000702c@yahoo.com> Content-Language: en-GB Bytes: 3614 On 27/11/2024 14:01, Michael S wrote: > On Wed, 27 Nov 2024 08:08:34 -0300 > Thiago Adams <thiago.adams@gmail.com> wrote: > >> On 27/11/2024 07:36, Michael S wrote: >>> On Tue, 26 Nov 2024 16:42:34 -0300 >>> Thiago Adams <thiago.adams@gmail.com> wrote: >>>> >>>> >>>> Yes..I realized now I am wrong. Considering function calls uses >>>> registers I think the old C model works only when passing >>>> everything on stack. >>>> >>>> >>> >>> "Old model" relies on programmer always using right types in the >>> function call. F(0) call Bart's example would not work even for >>> calling conventions in which both int and double passed on the same >>> stack, because [in typical pre-64-bit calling conventions] they >>> don't occupy the same space. For correct result you would have to >>> write it as F((double)0) or F(0.0). >>> >>> Alternatively "old model" could work when all things that are >>> allowed to be passed as function parameters are of the same size. >>> It seems, that's what they had in ancestors of C language and >>> probably in very early versions of C as well. It was no longer a >>> case in variant of the language described by 1st edition of K&R. >>> >> >> I will write in my own words. Correct me if I make a mistake. >> >> 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. > Before prototypes were added to C, I am not sure C was standardised enough to even ask about such functions! But AFAIK it is not possible to call a function with float arguments unless you use prototype declarations, even with modern C. The term you are looking for here is "default argument promotions". You get standard integer promotions on integer types of lower rank than "int", and floats are promoted to doubles.