[fpc-pascal] overflow checking

Пётр Косаревский ppkk at mail.ru
Fri Jun 23 10:59:26 CEST 2006


Just a question about programming practice:

How can I disable overflow checking for a couple of operations?

I use something like that:
{$DEFINE CHECKINGS}

{$IFDEF CHECKINGS} --- of course, this block can be much bigger
  {$R+,S+,Q+,V+}
{$ELSE}
  {$IMPLICITEXCEPTIONS ON}
  {$R-,S-,Q-,V-}
{$ENDIF}

...

a:=b+c;
{$Q-}
e:=f+g;
{$IFDEF CHECKINGS}
  {$R+,S+,Q+,V+}
{$ELSE}
  {$IMPLICITEXCEPTIONS ON}
  {$R-,S-,Q-,V-}
{$ENDIF}
h:=i+j;

etc

So I have many lines overhead each time.
Generally I try to disable checkings for bigger blocks, but it is somewhat lame.

Is there an easier way?
Like
{$SAVE Q} {$Q-} e:=f+g; {$LOAD Q}
so that it will fit one line?


I know, that I can split {$IF} block:
{$Q-} e:=f+g; {$IFDEF CHECK_OVRLW} {Q+} {$ENDIF}

Is this a better practice?



More information about the fpc-pascal mailing list