Re: function call
- From: "FreeRTOS.org" <noemail@xxxxxxxxx>
- Date: Thu, 31 Aug 2006 08:41:19 GMT
Hi,
I am a little confused by the following example:
portCHAR myaddress = 0xFF;
ReadRegister(myaddress);
void ReadRegister(portSHORT address);
The compiler isn't giving me a warning for using a portCHAR(8 bit) as a
parameter when portSHORT(16 bit) is used.
But even though I expected the compiler to do "something" and assign
0x00FF to address, this was not the case.
Inside the function ReadRegister "address" is 0x??FF with ?? being
something undeterministic.
It is not "auto-casting" to 0x00FF.
I am fine with this functionality ... but I don't get it why there is
no compiler warning.
Any ideas?
I think passing an 8bit type to a 16bit parameter would result in a silent
"integral promotion", and not result in a compiler warning by default. Take
care however regarding your sign. Whether the result was sign extended to
0xffff, or result in a positive 0x00ff is platform dependent, according to
the C standard.
Regards,
Richard.
+ http://www.FreeRTOS.org
+ http://www.SafeRTOS.com
for Cortex-M3, ARM7, ARM9, HCS12, H8S, MSP430
Microblaze, Coldfire, AVR, x86, 8051 & PIC18 * * * *
.
- References:
- function call
- From: Juergen
- function call
- Prev by Date: Re: Nice IDE for ARM?
- Next by Date: Re: Problem with SMTP mail and Siemens TI63
- Previous by thread: function call
- Index(es):
Relevant Pages
|