[fpc-pascal] overflow checking
Vinzent Hoefler
JeLlyFish.software at gmx.net
Fri Jun 23 11:41:12 CEST 2006
On Friday 23 June 2006 08:59, Пётр Косаревский wrote:
> I know, that I can split {$IF} block:
Well, if you do define CHECK_OVERFLW depending on the current compiler's
settings like this:
{$IFOPT Q+} {$DEFINE CHECK_OVRLW} {$ENDIF}
then ...
> {$Q-} e:=f+g; {$IFDEF CHECK_OVRLW} {Q+} {$ENDIF}
... this looks like one of the easiest ways.
> Is this a better practice?
Well, my practice is to use more lines, so that the instruction(s) in
question don't get hidden by all the compiler-directives surrounding
it.
Like this:
|{$IFOPT Q+} {$DEFINE OPT_Q} {$Q-} {$ENDIF}
|Bit_Working_Reg.L := (Bit_Working_Reg.L * $100) or
| Ifd.Lzw^.Input_Buf[Byte_Position_In_Buffer];
|{$IFDEF OPT_Q} {$UNDEF OPT_Q} {$Q+} {$ENDIF}
Your's is certainly shorter, but it depends on a global definition,
which is something I'm always trying to avoid.
Vinzent.
More information about the fpc-pascal
mailing list