[fpc-pascal] Using constants instead of comments

Vojtěch Čihák vojtech.cihak at atlas.cz
Wed Apr 18 13:34:15 CEST 2018


Hi,
 
Why not define?
 
{$DEFINE DEBUG}
 
{$IFDEF DEBUG} Writeln('diagnostic info'); {$ENDIF}
 
V.
 
______________________________________________________________
> Od: "James Richters" <james at productionautomation.net>
> Komu: "'FPC-Pascal users discussions'" <fpc-pascal at lists.freepascal.org>
> Datum: 18.04.2018 05:06
> Předmět: [fpc-pascal] Using constants instead of comments
>
I have a whole section of diagnostic writeln's in a program, and it's tedious to comment them all out/in as needed.   I'm curious if doing something like
 
 Const 
   diagnosticdetail=false;
 
 If diagnosticdetail then Writeln('diagnostic info');
 
 Is the same as 
 
 // Writeln('diagnostic info');
 
 And the Writeln will actually end up being left out of the compiled program altogether... since the constant will never allow it to run,  or if not, is there a better way to optionally exclude diagnostic information entirely from the compiled program?
 
 
 _______________________________________________
 fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal <http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180418/556c8e5d/attachment.html>


More information about the fpc-pascal mailing list