Deutsch   English   Français   Italiano  
<vi6uji$3ve13$3@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: Thiago Adams <thiago.adams@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: question about linker
Date: Wed, 27 Nov 2024 08:08:34 -0300
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <vi6uji$3ve13$3@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Nov 2024 12:08:35 +0100 (CET)
Injection-Info: dont-email.me; posting-host="55a7253bc8aad96d55ac3768212cd6ac";
	logging-data="4175907"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18cSUqjH12NsTcfKoXjRbl0h8BIaHbuAK8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:w7JBC6uSklp6tEelculzPSWOQ0k=
In-Reply-To: <20241127123616.00003269@yahoo.com>
Content-Language: en-US
Bytes: 2621

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.