#pragma map

Applies to C Applies to C++

Description

The #pragma map directive tells the compiler that all references to an identifier are to be converted to "name".

Syntax


Syntax Diagram

where:


identifier A name of a data object or a nonoverloaded function with external linkage.
Applies to C++ 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.
Applies to C++ 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

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.

Examples

Example 1 Applies to C

int funcname1()
{
    return 1;
}
 
#pragma map(func , "funcname1")    /* maps func to funcname1 */
 
int main()
{
   return func();       /* no function prototype needed in C */
}
 

Example 2 Applies to C++

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 Applies to C++

#pragma map(foo, "bar")
 
int foo();             //function prototypes needed in C++
 
int main()
{
   return foo();
}
 
extern "C" int bar() {return 7;}

Related References

General Purpose Pragmas IBM Copyright 2003