Liste des Groupes | Revenir à cl c |
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.
Les messages affichés proviennent d'usenet.