rename (#import)


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at rename (#import). C++ Specific

Works around name collision problems.



Old name in the type library.

Name to be used instead of the old name.

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

This attribute can be used when a name in the type library coincides with a macro definition in the system header files. If this situation is not resolved, then various syntax errors will be generated, such as Compiler Error C2059 and Compiler Error C2061.

System_CAPS_ICON_note.jpg 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:


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


This is because the name GetMyParent only occurs in the resulting type library header file.

END C++ Specific

#import Attributes
#import Directive