You are hereForums / Coding / FreeBASIC / Snippets / xAssert debugging macro, ensure correctness even when not compiling for debug like assert

xAssert debugging macro, ensure correctness even when not compiling for debug like assert


1 post / 0 new
Last post
sir_mud's picture
Offline
Joined: 12/25/2009
xAssert debugging macro, ensure correctness even when not compiling for debug like assert

[freebasic]
#define xassert(v) if not (v) then print using "Error on line: ##### in file:'&', & is not true."; __LINE__, __FILE__, #v

var x = new integer
'delete x
xassert(x <> 0)
delete x : x = 0
xassert(x <> 0)
[/freebasic]

I could see an extended version of this becoming a part of the extended library,
something like you can setup a handler function to catch the assert errors
so you can do with them what you want.


Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway.
Andrew S. Tanenbaum