#pragma map

Purpose

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

Syntax

Read syntax diagramSkip visual syntax diagram
#pragma map syntax (C only)

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

Read syntax diagramSkip visual syntax diagram
#pragma map syntax (C++ only)

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

Parameters

name1
The name used in the source code. C only name1 can represent a data object or function with external linkage. C only C++ only name1 can represent a data object, a non-overloaded or overloaded function, or overloaded operator, with external linkage. C++ only If the name to be mapped is not in the global namespace, it must be fully qualified.

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 anywhere in the program.

C++ only argument_list
The list of arguments for the overloaded function or operator function designated by name1. If name1 designates an overloaded function, the function must be parenthesized and must include its argument list if it exists. If name1 designates a non-overloaded function, only name1 is required, and the parentheses and argument list are optional. C++ only
name2
The name that will appear in the object code. C only name2 can represent a data object or function with external linkage. The compiler preserves mixed-case names. If the name is longer than 8 characters, you must use the binder and specify the LONGNAME compiler option. C only

C++ only name2 can represent a data object, a non-overloaded or overloaded function, or overloaded operator, with external linkage. If the name is longer than 8 characters you must use the binder. name2 must be specified using its mangled name. To obtain C++ mangled names, compile your source to object files only, using the -c compiler option, and use the nm operating system command on the resulting object file. C++ only

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 #pragma csect directive in the same compilation unit. The map name2 is not affected by the CONVLIT or the ASCII compiler options.

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.

C++ only #pragma map will look at the declarations prior to it and if satisfied will map the declaration. If it is not satisfied, it will check all declarations at the end of the compilation to see if it can find a match. C++ only

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 (using the mangled name for the map name in C++):
/* Compilation unit 1: */

#include <stdio.h>

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

#if __cplusplus
#pragma map (foo, "bar__Fv")
#else
#pragma map (foo, "bar")
#endif
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!