[MPlayer-dev-eng] Fixing the GCC-3.3 and scale code mess

Rich Felker dalias at aerifal.cx
Tue Jun 28 23:46:32 CEST 2005


On Tue, Jun 28, 2005 at 11:13:07PM +0200, Luca Barbato wrote:
> Zoltan Hidvegi wrote:
> 
> > 
> > Yes, that's the best solution, and it will even speed up C code on
> > 64-bit machines, as the compiler no longer need to generate
> > unnecessary truncate and extend instructions.  int and unsigned local
> > variables and function arguments should all be changed to long and
> > unsigned long, and everyone should kick the habbit of using int.  int
> > and unsigned should *never* be used, if someone needs a specific data
> > size, use int32_t, otherwise, use long and unsigned long.
> 
> I miss the point.

Apparently in modern times, "long" is the system wordsize rather than
int. This is because C ran out of type names... ;)

> > I tend to
> > like unsigned long the most, but it is too long to write, so I usually
> > like to have a typedef to ulong.  But ulong is defined by some systems
> > in system headers, so it is a bit of mess to get it right, because in
> > C, you cannot typedef ulong if it was already typedefed before, even
> > if it is the same type.
> 
> That's why you should avoid typedeffing base types...

Yes. typedef is NOT for making clever shorthand. It's for when you
need to define a type that might be different from one platform to
another, or with different compiletime options (fixed point versus
float) etc. Generally you do not want unsigned except maybe with char,
so i see it as a good thing that you have to write out the whole word
every time you want to use it.

Rich




More information about the MPlayer-dev-eng mailing list