[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] typecast

From: David Breeze
Subject: Re: [avr-gcc-list] typecast
Date: Wed, 26 Mar 2003 08:01:30 +0000

Don't blame gcc for the typecasting reqirement.  It is not only good practice 
to use typecasting but a requirement at the higher levels of C compliance.  Try 
passing your code through Lint at even the lower requirement levels 2 or 3 and 
it will throw out code which is not type cast where required.

David Breeze

>>> "Sander Pool" <address@hidden> 25 March 2003 23:30:08 >>>

I appologize for being the n'th person with the identical reply. Well, I
added a small rant about gcc :-)

Next time I'll read my entire inbox before replying. I was so exited I knew
the answer to a question I just -had- to send it :-)


----- Original Message -----
From: "Sander Pool" <address@hidden>
To: "Torsten Hahn" <address@hidden>; <address@hidden>
Sent: Tuesday, March 25, 2003 3:21 PM
Subject: Re: [avr-gcc-list] typecast

> I've been bitten by type conversions quite a bit in the last few weeks, it
> seems you really really have to spell it out to gcc to make it do the
> thing. But that's not what you were asking :-)
> If you want to have the MSBs of a 16 bit number and stick them in an 8 bit
> variable you could do:
> number8 = (uint8_t) (number16 >> 8);
> This -should- discard the 8 MSBs of the right shifted number, leaving you
> the original 8 MSBs from number16.
>     Sander

avr-gcc-list mailing list

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed.  If 
an addressing or transmission error has misdirected this e-mail, please notify 
the author by replying to this e-mail.  If you are not the intended recipient 
you must not use, disclose, copy, print or rely on this e-mail.

Joy Mining Machinery Limited/P&H Minepro Services aims to prevent the 
propagation of viruses, but cannot guarantee that this email is virus free.  
You are advised to scan all attachments and open them at your own risk.

Joy Mining Machinery Limited/P&H Minepro Services may monitor outgoing and 
incoming e-mails and other telecommunications on its e-mail and 
telecommunication systems.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]