- Ursprüngliche Nachricht -
Von: Peter Bigot
Gesendet am: 07 Okt 2010 20:21:49
Third time's the charm? It's been so long since I've dealt with KR C I've
forgotten the rules.
The behavior is correct. char and short are upcast to int when no
declaration is in scope. Integral types
I had a function which took a byte argument and returned a byte. From
another file (compiled into a separate object), I called the function
without first declaring it. The calling function used an argument which
evaluated to uint32_t.
In the called function, it looked for the argument in R15.
That's not an ABI problem. Without a declaration available at the point of
call, C mandates that the parameter be assumed to be an int (two bytes). If
you define a function with non-int parameters, you have to have a compatible
declaration in scope wherever it's invoked. Using to mask off
Hi Kim,
On Thu, 7 Oct 2010 08:26:15 -0400
Kim Toms kim.t...@gmail.com wrote:
I had a function which took a byte argument and returned a byte. From
another file (compiled into a separate object), I called the function
without first declaring it. The calling function used an argument which
So does that mean that calling a function which takes an int with a byte
won't work? Or, alternatively, that calling a function with a byte that
expects an int won't work? Because, in my experience that does seem to
work. Maybe I haven't run across the problem in other contexts, though.
I
Sorry, you're right: I read this too quickly.
I don't think it's an ABI problem so much as a compiler problem: it's
actually passing the 32-bit value in registers r14 and r15, instead of
truncating it to an int and passing it in r15, as it's supposed to do when
there's no declaration.
Fine. Yet
Third time's the charm? It's been so long since I've dealt with KR C I've
forgotten the rules.
The behavior is correct. char and short are upcast to int when no
declaration is in scope. Integral types that are larger than int are left
as is. That you're masking off all but the low byte does
OK, thanks. Good to know. I'll go back and put a bookmark in my KR :-)
On Thu, Oct 7, 2010 at 2:21 PM, Peter Bigot p...@peoplepowerco.com wrote:
Third time's the charm? It's been so long since I've dealt with KR C I've
forgotten the rules.
The behavior is correct. char and short are