#pragma map

Category

Object code control

Purpose

Converts all references to an identifier to another, externally defined identifier.

Syntax

Read syntax diagramSkip visual syntax diagram
#pragma map syntax – C

>>-#--pragma--map--(--name1--,--"--name2--"--)-----------------><

Parameters

name1
The name used in the source code. name1 can represent a data object or function with external linkage.

name1 should be declared in the same compilation unit in which it is referenced, but should not be defined in any other compilation unit. name1 must not be used in another #pragma map directive or any assembly label declaration anywhere in the program.

name2
The name that will appear in the object code. name2 can represent a data object or function with external linkage.

If the name exceeds 65535 bytes, an informational message is emitted and the pragma is ignored.

name2 may or may not be declared in the same compilation unit in which name1 is referenced, but must not be defined in the same compilation unit. Also, name2 should not be referenced anywhere in the compilation unit where name1 is referenced. name2 must not be the same as that used in another #pragma map directive or any assembly label declaration in the same compilation unit.

Usage

The #pragma map directive can appear anywhere in the program. Note that in order for a function to be actually mapped, the map target function (name2) must have a definition available at link time (from another compilation unit), and the map source function (name1) must be called in your program.

You cannot use #pragma map with compiler built-in functions.

Examples

The following is an example of #pragma map used to map a function name:
/* Compilation unit 1: */

#include <stdio.h>

void foo();
extern void bar(); /* optional */


#pragma map (foo, "bar")

int main()
{
foo();
}

/* Compilation unit 2: */

#include <stdio.h>

void bar()
{
printf("Hello from foo bar!\n");
}
The call to foo in compilation unit 1 resolves to a call to bar:
Hello from foo bar!

Related information