[lazarus] Better proposition for debug code.

Michael Van Canneyt michael.vancanneyt at wisa.be
Wed Jul 21 08:17:38 EDT 1999


Hello,

May I remind you that the compiler supports the ASSERT() construct of Delphi;
that you can specify a
  AssertErrorProc
which takes care of the asserts ?

This means that you can have the whole debug class stuff without the
juggling with macros.

Just do a

 Assert(False,'Some debug message');

The assertErrorProc will then give you the line number, source file and this message.

Assert code is compiled in or not depending on the LOCAL switch:
{$ASSERTIONS ON}

So they can be switched on or off at will, if they are off, no code is even generated.

better yet; you can implement debug levels thus:

 Assert(Debug.Debuglevel>2,'Some serious error');
 Assert(Debug.DebugLevel=3,'Some esoteric error');

Just an idea; why use ugly constructs with macros if you can have more (i.e. source
and line number) with this compiler construct ?

Michael.






More information about the Lazarus mailing list