XS1 Data Types

The size and alignment of C and XC’s data types are not specified by the language. This allows the size of int to be set to the natural word size of the target device, ensuring the fastest possible performance for many computations. It also allows the alignment to be set wide enough to enable efficient memory loads and stores. the table below represents the size and alignment of the data types specified by the xCORE Application Binary Interface, which provides a standard interface for linking objects compiled from both C and XC.

Data TypeSizeAlignSupportedMeaning
 (bits)(bits)XCC 

char88YYCharacter type
short1616YYShort integer
int3232YYNative integer
long3232NYLong integer
long long6432NYLong long integer
float3232NY32-bit IEEE float
double6432NY64-bit IEEE float
long double6432NY64-bit IEEE float
void *3232NYData pointer
port3232YNPort
timer3232YNTimer
chanend3232YNChannel end

In addition:

  • The char type is by default unsigned.
  • The types char, short and int may be specified in a bit-field’s declaration.
  • A zero-width bit-field forces padding until the next bit-offset aligned with the bit-field’s declared type.
  • The notional transfer type of a port is unsigned int (32 bits).
  • The notional counter type of a port is unsigned short (16 bits).
  • The notional counter type of a timer is unsigned int (32 bits).