Edit

Share via


rename import attribute

C++ Specific

Works around name collision problems.

Syntax

#import type-library rename( "OldName" , "NewName" )

Parameters

OldName
Old name in the type library.

NewName
Name to be used instead of the old name.

Remarks

When the rename attribute is specified, the compiler replaces all occurrences of OldName in type-library with the user-supplied NewName in the resulting header files.

The rename attribute can be used when a name in the type library coincides with a macro definition in the system header files. If this situation isn't resolved, the compiler may issue various syntax errors, such as Compiler Error C2059 and Compiler Error C2061.

Note

The replacement is for a name used in the type library, not for a name used in the resulting header file.

For example, suppose a property named MyParent exists in a type library, and a macro GetMyParent is defined in a header file and used before #import. Since GetMyParent is the default name of a wrapper function for the error-handling get property, a name collision will occur. To work around the problem, use the following attribute in the #import statement:

#import MyTypeLib.tlb rename("MyParent","MyParentX")

which renames the name MyParent in the type library. An attempt to rename the GetMyParent wrapper name will fail:

#import MyTypeLib.tlb rename("GetMyParent","GetMyParentX")

It's because the name GetMyParent only occurs in the resulting type library header file.

END C++ Specific

See also

#import attributes
#import directive