4.2.5. if

The simplest form of a macro conditional statement.

Syntax:


if (expression)                  /* If this expression is True */
{
    statement;                   /* execute this statement */
    [statement;]...              /* additional statements */
}

Description

The if statement is the simplest form of a macro conditional statement. It is always followed by an expression enclosed in parentheses. If the expression evaluates to zero, that is False, the statement following the expression is bypassed. If the expression evaluates to a value other than zero, that is True, the statement following the expression is executed. If you have more than one statement in the if statement these must be enclosed in curly braces ({}).

Return Value

None

Rules

None

Example

This example shows how to use if in a macro:


if (n==0)
  strcpy(number,"zero");

Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0175H
Non-Confidential