[Top][All Lists]

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

RE: [avr-gcc-list] AVR-GCC question

From: Trampas
Subject: RE: [avr-gcc-list] AVR-GCC question
Date: Mon, 23 May 2005 16:12:00 -0400

I don't think that is portable. That is I know some 16 bit processors and
compilers will report an INT16 as being sizeof 1. That is sizeof for word
addressable machines may report a char as 1 and a 16 bit variable as 1. Thus
sizeof is not always number of bytes, like it is for the X86.  Rather sizeof
is the number of smallest storage locations required for the variable. 


-----Original Message-----
From: Jeff Epler [mailto:address@hidden 
Sent: Monday, May 23, 2005 3:53 PM
To: Trampas
Cc: address@hidden
Subject: Re: [avr-gcc-list] AVR-GCC question

I understand what you're getting at, but at least one of your problems
can be solved by gcc today.  This works (well, I tested on x86 linux
only) and doesn't seem to require any compiler extensions:
#include <limits.h>
#define MAX_SIGNED(x) (double)((1ull<<(CHAR_BIT * sizeof(x) - 1))-1)

Using this macro, though, the signed char -128 goes to a value below
-1.0.  I think that's the same thing your code did.


reply via email to

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