Skip to content

Assertwarn

Paul Squires edited this page Oct 14, 2026 · 2 revisions

Home › Miscellaneous Keywords › AssertWarn

AssertWarn

Debugging macro that prints a warning if an expression evaluates to 0.

Syntax

#define AssertWarn(expression) If (expression) = 0 Then : fb_AssertWarn( __FILE__, __LINE__, __FUNCTION__, #expression ) : End If

Parameters

  • expression
  • expression

Description

The AssertWarn macro is intended for use in debugging and works only if the -g option is selected in the compiler command line. In this case it prints a warning message if expression evaluates to 0. It doesn't stop the program execution like Assert does.

Its normal use is to check the correct value of the variables during debugging.

If -g is not passed to the compiler, the macro does not generate any code.

Remarks

Usage

AssertWarn( expression )

Dialect Differences

  • Not available in the -lang qb dialect unless referenced with the alias __ASSERTWARN.

Differences from QB

  • New to FreeBASIC

See also

Examples

Sub foo

  Dim a As Integer

  a=0

  AssertWarn(a=1)

End Sub

foo

'' If -g is used this code prints: test.bas(3): assertion failed at FOO: a=1

Category: Miscellaneous Keywords
Kind: keyword


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally