On Monday 09 November 2009 10:28 Chris Liechti wrote:
> Why is that a bug? your numbers are ints it does an int calculation an
> then extends the result to store it/ return it (the rules when C does
> implicit casts are not always intuitive :/ )
My apologies, you are of course correct. In fact, best practice would be:
#include <sys/inttypes.h>
static int32_t bugfree(void)
{
int32_t debugged;
debugged = (int32_t)1 << 30;
return( debugged );
}
This is almost portable, but for the fact that inttypes.h is in sys on
msp430gcc. Is there any compelling reason for this?
--
Rick Jenkins <[email protected]>
Hartman Technica http://www.hartmantech.com
Phone +1 (403) 230-1987
221 35 Avenue. N.E., Calgary, Alberta, Canada T2E 2K5