[lazarus] Better proposition for debug code.

Peter Vreman pfvreman at wins.uva.nl
Wed Jul 21 08:36:52 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 ?
Even in gtk and all other big libraries asserts are used. See all the
error messages from gtk you'll get, they are all assert() calls.

Peter







More information about the Lazarus mailing list