Keil™, An ARM® Company

RealView Linker and Utilities Guide

Using preprocessing directives

5.3.9. Using preprocessing directives

Use the first line in the scatter-loading description file to specify a preprocessor that the linker invokes to process the file. This command is of the form:

#! <preprocessor> [pre_processor_flags]

Most typically the command is #! armcc ‑E.

The linker can carry out simple expression evaluation with a restricted set of operators, that is, +, , *, /, AND, OR, and parentheses. The implementation of OR and AND follows C operator precedence rules.

You can add preprocessing directives to the top of the scatter-loading description file. For example:

#define ADDRESS 0x20000000
#include "include_file_1.h"

The linker parses the preprocessed scatter-loading description file where these are treated as comments and ignored.

Consider the following simple example:

#define AN_ADDRESS (BASE_ADDRESS+(ALIAS_NUMBER*ALIAS_SIZE))

Use the directives:

#define BASE_ADDRESS 0x8000
#define ALIAS_NUMBER 0x2
#define ALIAS_SIZE 0x400

If the scatter-loading description file contains:

LOAD_FLASH AN_ADDRESS    ; start address

Following preprocessing, this evaluates to:

LOAD_FLASH ( 0x8000 + ( 0x2 * 0x400 ))  ; start address

Following evaluation, the linker parses the scatter-loading file to produce the load region:

LOAD_FLASH 0x8808 ; start address

See Specifying memory map information for the image for more information on using --predefine command-line option.

Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0377A