#pragma map

Description

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.

Syntax

Read syntax diagramSkip visual syntax diagram>>-#--pragma--map--(--+-identifier---------+--,--"name"--)-----><
                      '-function_signature-'

where:

identifier A name of a data object or a nonoverloaded function with external linkage.
C++ only If the identifier is the name of an overloaded function or a member function, there is a risk that the pragma will override the compiler-generated names. This will create problems during linking.
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.
C++ only Specify the mangled name if linking into a C++ name (a name that will have C++ linkage signature, which is the default signature in C++). See Example 4, in the Examples section below.

Notes

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.

Examples

Example 1 C only

int funcname1()
{
    return 1;
}

#pragma map(func , "funcname1")	//maps func to funcname1 

int main()
{
   return func();	// no function prototype needed in C
}

Example 2 C++ only

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 C++ only

#pragma map(foo, "bar")

int foo();		//function prototypes needed in C++

int main()
{
   return foo();
}

extern "C" int bar() {return 7;}

Example 4 C++ only

#pragma map(foo, "bar__Fv")

int foo();		//function prototypes needed in C++



int main()
{
   return foo();
}

int bar() {return 7;}
Note:
You can avoid using the mangled name bar_FV by declaring bar as having C linkage. See Example 3, above.

The following examples illustrate several cases which interaction between pragma map and assembly labels may generate error message.

Example 5

#pragma map(a, "abc")
 
//error, since the label name is the same as a map name to a 
differen 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 asm 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 has already have an asm 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 decleration, Since "a" is mapped to the same name 
 #pragma map(a, "abc")