[fpc-pascal] Using constants instead of comments
r030t1 at gmail.com
Wed Apr 18 05:55:12 CEST 2018
On Tue, Apr 17, 2018 at 10:06 PM, James Richters
<james at productionautomation.net> wrote:
> 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
> 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?
In C typically you would use conditional compilation. This would work
well in FPC as well. Or, you can do what is more often done in higher
level or managed languages, which is to use a log function that
behaves differently based on the verbosity level.
More information about the fpc-pascal