{{fbdoc item="title" value="ASSERT"}}----
Debugging macro that halts program execution if an expression is evaluated to ##0## (false).

{{fbdoc item="syntax"}}##
	[[KeyPgPpdefine|#define]] **ASSERT**(//expression//) [[KeyPgIfthen|if]] (expression) = 0 [[KeyPgThen|then]] : fb_Assert( [[KeyPgDdfile|__FILE__]], [[KeyPgDdline|__LINE__]], [[KeyPgDdfunction|__FUNCTION__]], [[KeyPgOpPpStringize|#]]expression ) : [[KeyPgEndif|end if]]
##
{{fbdoc item="usage"}}##
	**ASSERT**( //expression// )
##
{{fbdoc item="param"}}
	##//expression//##
		Any valid conditional/numeric expression.  If ##//expression//## evaluates to ##0## (i.e. "false"), execution is halted.

{{fbdoc item="desc"}}
	The ##**ASSERT**## macro is intended for use in debugging and works only if the ##[[CompilerOpteassert|-g]]## or [[CompilerOpteassert|-eassert]]## option is specified on the ##fbc## command line. In this case it prints an error message and stops the program execution if ##//expression//## evaluates to ##0##.
	
	Its normal use is to check the correct value of the variables or expressions during debugging.
	
	If ##[[CompilerOpteassert|-g]]## and [[CompilerOpteassert|-eassert]]## are not passed to fbc, the macro does not generate any code, and has no effect.
	
	Note: If an ##**ASSERT**## fails while the program is in a graphics ##[[KeyPgScreengraphics|Screen (Graphics)]]##, the error message will not be visible as it will be printed to the graphics screen, which will be closed immediately after.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/debug/assert.bas"}}%%(freebasic)
sub foo
 dim a as integer
 a=0
 assert(a=1)
end sub

foo 

'' If -g or -eassert is used, this code stops with: test.bas(3): assertion failed at FOO: a=1 
%%

{{fbdoc item="lang"}}
	- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__ASSERT""**##.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- ##[[KeyPgPpassert|#assert]]##
	- ##[[KeyPgAssertwarn|ASSERTWARN]]##
	- [[CompilerOpteassert|Compiler Option: -eassert]]
	- [[CompilerOptg|Compiler Option: -g]]
	
{{fbdoc item="back" value="CatPgMisc|Miscellaneous"}}