The #pragma map directive tells the compiler that all references to an identifier are to be converted to "name". "name" is then used in the object file and any assembly code.
>>-#--pragma--map--(--+-identifier---------+--,--"name"--)----->< '-function_signature-'
where:
identifier | A name of a data object or a nonoverloaded function with external linkage.
![]() |
function_signature | A name of a function or operator with internal linkage. The name can be qualified. |
name | The external name that is to be bound to the given object, function,
or operator.
![]() |
The compiler emits a severe error message when the label name is the same as:
You should not use #pragma map to map the following:
The directive can appear anywhere in the program. The identifiers appearing in the directive, including any type names used in the prototype argument list, are resolved as though the directive had appeared at file scope, independent of its actual point of occurrence.
If the name specified with pragma map exceeds 65535 bytes, an information message is emitted and the pragma is ignored.
Example 1
int funcname1() { return 1; } #pragma map(func , "funcname1") //maps func to funcname1 int main() { return func(); // no function prototype needed in C }
Example 2
extern "C" int funcname1() { return 0; } extern "C" int func(); //function prototypes needed in C++ #pragma map(func , "funcname1") // maps ::func to funcname1 int main() { return func(); }
Example 3
#pragma map(foo, "bar") int foo(); //function prototypes needed in C++ int main() { return foo(); } extern "C" int bar() {return 7;}
The following examples illustrate several cases which interaction between #pragma map and assembly labels may generate an error message.
Example 5
#pragma map(a, "abc") // error, since the label name is the same as a map name to a // different identifier int cba asm("abc");
Example 6
int abc asm("myID"); //error, since the same label is used on two different variables int cba asm("myID");
When an asm label specification is applied to a declaration with a different label name than previously specified in a pragma map, the compiler generates an error message.
Example 7
#pragma map(a, "aaa") // severe error, since "a" is already mapped by pragma map to a // different name void a() asm("bbb");
Example 8
#pragma map(a, "aaa") // Valid declaration, Since "a" is mapped to the same name int a asm("aaa");
When a pragma map specifies a mapped name for an identifier, which conflicts with the mapped name from a previous assembly label on a different declaration, the #pragma map is ignored with a warning message.
Example 9
int a asm("abc"); // Warning message, since 'abc' is already used as a label name #pragma map(b, "abc")
When a #pragma map tries to map an identifier that already has an assembly label, the pragma map is ignored with a warning message.
Example 10
int a asm("abc"); //Warning, since 'a' already has a label, pragma map is ignored #pragma map(a, "aaa")
Example 11
int a asm("abc"); // Valid declaration, Since "a" is mapped to the same name #pragma map(a, "abc")