Data types and portability

I’d like to know what is better to use, languaje types (int, short int) or
Uint types, to achieve a maximun portability.–
Roger D. Vargas | "Humans have so many emotions, Artoo. And most
VQt Development Team | seem to cause them pain. I do not understand,
http://vqt.sourceforge.net | but I’m glad I have none. And yet – I can’t help
wondering sometimes… what it would be like."
C-3PO, Protocol Droid. Star Wars 2: World of Fire.

“Roger D. Vargas” wrote:

I’d like to know what is better to use, languaje types (int, short int) or
Uint types, to achieve a maximun portability.

Use the UintXX/SintXX types wherever you have to have something of a specific
size, i.e. when reading a binary file format. Other places where size doesn’t
matter, use the built-in C types.

~jeffrey :j

I find it is best to use the system types (int, short…) for variables
where you know the maximum value won’t go over a certain amount. For
example if you know that value of an variable you are using won’t go over
2^16 then just use the type ‘int’ because all systems support an int of at
least 16 bits. I only use the defined size types (Uint8…) for items like
structs that I will be sending across the network to other platforms, or
other things where the actual size (in bytes, not value) matters.

http://www.mongeese.orgOn Sat, 3 Feb 2001, Roger D. Vargas wrote:

I’d like to know what is better to use, languaje types (int, short int) or
Uint types, to achieve a maximun portability.


Roger D. Vargas | "Humans have so many emotions, Artoo. And most
VQt Development Team | seem to cause them pain. I do not understand,
http://vqt.sourceforge.net | but I’m glad I have none. And yet – I can’t help
wondering sometimes… what it would be like."
C-3PO, Protocol Droid. Star Wars 2: World of Fire.

I’d like to know what is better to use, languaje types (int, short int) or
Uint types, to achieve a maximun portability.

Definitely use the Uint types if you’re at all concerned with the limits a
number may get to. Try compiling an SDL app on an Itanium or Alpha someday
and you’ll get a greater mess with language types rather than the types
SDL provides for you. Presumably, by the time Itanium processors (or
other 64-bit architectures) are common, SDL’s autoconf scripts will be
able to determine the proper typedef that will produce a 32-bit signed
integer, which is probably going to be something other than what you
assumed in this era of 32-bit machines. I had trouble porting 16-bit apps
to 32-bit several years ago precisely because of this, and I can tell you
that it’s about as bad as debugging memory leaks (which sometimes result
because of false assumptions about integer size). The bugs you get here
are subtle, and that subtlety is their main annoyance.On Sat, 3 Feb 2001, Roger D. Vargas wrote:


Rafael R. Sevilla <@Rafael_R_Sevilla> +63 (2) 4342217
ICSM-F Development Team, UP Diliman +63 (917) 4458925
OpenPGP Key ID: 0x0E8CE481