Predefined Data Types


In C and C++ code, use the AlTypes.h typedefs when referring to integral types. These typedefs provide an easy way to specify the word size of an integer variable in a cross-platform manner. The typedefs found in the AlTypes.h file provide definitions for the platforms most commonly used at A&L; when starting a project on a platform that's not yet represented in AlTypes.h, please provide definitions.

The types in AlTypes.h are:

typedef

range

typical definition

SInt8

-128..127

signed char

UInt8

0..255

unsigned char

SInt16

-32768..32767

short

UInt16

0..65535

unsigned short

SInt32

-231..(231)-1

long int

UInt32

0..232 - 1

unsigned long int

SInt64

-263..(263)-1

long long int

UInt64

0..264 - 1

unsigned long long int

Note that not all legacy or embedded platforms provide the underlying support for 64-bit data types.

A typical AlTypes.h looks like:

#ifndef h_AlTypes
#define h_AlTypes

#ifdef _WINDOWS
// Microsoft Visual C++ Version
typedef char               SInt8;
typedef unsigned char      UInt8;
typedef short              SInt16;
typedef unsigned short     UInt16;
typedef long               SInt32;
typedef unsigned long      UInt32;
typedef __int64            SInt64;
typedef unsigned __int64   UInt64;

#else // Macintosh version
   #ifndef __MACTYPES__
      //typedef char SInt8;
      typedef unsigned char UInt8;
      typedef short SInt16;
      typedef unsigned short UInt16;
      typedef long SInt32;
      typedef unsigned long UInt32;
      typedef long long SInt64;
      typedef unsigned long long UInt64;
   #endif

#endif

#endif  /* This must be the final line in this file. */

Each project should make modifications as appropriate for the platform and compiler in use.