Skip to main content

IAR Embedded Workbench for Arm 9.70.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>}

#message "message"

#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.

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 is similar to the C89 standard.

Note

The preprocessor expressions use the same precedence rules as the assembler operators.

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.

#message

Generates a message on standard output.

#pragma

This directive is recognized but ignored.

#undef

Undefines a preprocessor symbol.

Table 153. 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.