Skip to main content

IAR Embedded Workbench for RH850 3.20.x

C-style preprocessor directives

In this section:
Syntax

#define symbol text

#elif condition

#else

#endif

#error "message"

#if condition

#ifdef symbol

#ifndef symbol

#include {"filename" | <filename>}

#line line-no {"filename"}

#undef symbol

Parameters

condition

An absolute assembler expression, see Expressions, operands, and operators.

The expression must not contain any assembler labels or symbols, and any non-zero value is considered as true. The C preprocessor operator defined can be used.

filename

Name of file to be included or referred.

line-no

Source line number.

message

Text to be displayed.

symbol

Preprocessor symbol to be defined, undefined, or tested.

text

Value to be assigned.

Description

The assembler has a C-style preprocessor that follows the C99 standard.

These C-language preprocessor directives are available:

Directive

Description

#define

Assigns a value to a preprocessor symbol.

#elif

Introduces a new condition in an #if...#endif block.

#else

Assembles instructions if a condition is false.

#endif

Ends an #if, #ifdef, or #ifndef block.

#error

Generates an error.

#if

Assembles instructions if a condition is true.

#ifdef

Assembles instructions if a preprocessor symbol is defined.

#ifndef

Assembles instructions if a preprocessor symbol is undefined.

#include

Includes a file.

#line

Changes the source references in the debug information.

#pragma

Controls extension features. The supported #pragma directives are described in Pragma directives.

#undef

Undefines a preprocessor symbol.

Table 129. C-style preprocessor directives  


You must not mix assembler language and C-style preprocessor directives. Conceptually, they are different languages and mixing them might lead to unexpected behavior, as an assembler directive is not necessarily accepted as a part of the C preprocessor language.

Note

The preprocessor directives are processed before other directives. As an example, avoid constructs like:

redef       macro                   ; Avoid the following!
#define \1 \2
            endm

because the \1 and \2 macro arguments are not available during the preprocessing phase.