Sign in Join
Wiki copytemporary

maxint/fr

Deutsch · English · Français · Suomi

MAXINT est un constante globale, égale à la limite supérieure du type integer, per the ISO 7185 standard.

Notez que cette valeur varie avec le compilateur indépendamment des capacités de la machine hôte ou de la cible (donc portabilité assurée entre des machines différentes ayant la même compilateur).

Si vous voulez contrôler la taille de l'espace d'adressage, contrôlez sizeof(pointer).

Si vous voulez savoir si vous exécuter sur un CPU avec 64-bit ALU, contrôlez si le symbole cpu64 est défini.

L'exemple suivant illustre comment ces valeurs sont articulées :

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

Comparez le résultat avec -Mtp puis -Mobjfpc, par exemple :

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

From the Free Pascal wiki, page "maxint/fr", as it stood on 2020-02-20 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.