From Free Pascal wiki
Jump to navigationJump to search

Deutsch (de) English (en) suomi (fi) français (fr)

MAXINT is a global constant, equal to the upper bound of the integer type, per the ISO 7185 standard.

Note that this value changes based on the compiler mode and has nothing to do with the capabilities of the host or target machine.

If you want to check the size of the address space, check sizeof(pointer).

If you want to know if you are running on a CPU with 64-bit ALU, check whether the symbol cpu64 is defined.

The following example illustrates how these values relate:

program maxvals;
  const width = 20;
  writeln( 'these change depending on compiler mode:' );
  writeln( '----------------------------------------' );
  writeln( 'maxint:           :', maxint : width );
  writeln( 'high( integer )   :', high( integer ) : width );
  writeln( 'constant, regardless of mode or target: ' );
  writeln( '----------------------------------------' );
  writeln( 'high( int32 )     :', high( int32 ) : width );
  writeln( 'high( int64 )     :', high( int64 ) : width );
  writeln( 'variable, depending on target cpu:' );
  writeln( '----------------------------------------' );
  writeln( 'sizeof( pointer ) :', sizeof( pointer ) : width );
  writeln( 'compile-time definitions:' );
  writeln( '----------------------------------------' );
  {$IFDEF cpu64} writeln( 'cpu64' ); {$ENDIF}
  {$IFDEF cpu32} writeln( 'cpu32' ); {$ENDIF}
  {$IFDEF cpu16} writeln( 'cpu16' ); {$ENDIF}

Compare the results with -Mtp vs -Mobjfpc, for example:

fpc -Mtp maxvals.pas && ./maxvals
fpc -Mobjfpc maxvals.pas && ./maxvals