Linux-Hams archive - July 1998: Re: sizeof()

Re: sizeof()

Kai Schulte (njjoqk@swissonline.ch)
Tue, 7 Jul 1998 02:31:24 +0200 (MESZ)


On Mon, 6 Jul 1998, Matthias Welwarsky wrote:

> Don't care about memory that much, care about speed. In most
> cases, int defaults to a width that the system can handle fast. Don't
> use char as a loop counter even if the range fits, most of the time it
> will be slower than int.

Definitely... I once used an array of short ints with Linux and everything
became incredibly slow. I still cast them to 16-bit before writing them
to a file, though, because somebody was going to use the results on a DOS
machine.

> And of course, don't write code that depends on
> the size of simple types like int, short and long.

This was just what I was asking about: Theoretically, you might run into
a machine that has an 8-bit "int" and an 8-bit "long", and that would
break almost any application.

> Use typedefs and provide a types.h depending on the target architecture.

Yes, that sounds _really_ clean :)

Kai