Description of the no_function_mapping compiler directive and the implementation_key compiler directive in Visual C++ .NET or in Visual C++ 2005 (832688)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2002)
  • Microsoft Visual C++ 2005 Express Edition

SUMMARY

This article describes the no_function_mapping compiler directive and the implementation_key compiler directive. This article also describes the compiler errors that you may receive when you use the implementation_key compiler directive. Additionally, it describes how you can resolve the compiler errors for the implementation_key compiler directive.

SYMPTOMS

When you compile the code, you may receive the following error message:
error 2143: syntax error : missing ';'

CAUSE

The implementation_key compiler directive is a compiler-injected directive that is used when a Component Object Model (COM) interface has more than 1000 methods. The Microsoft Visual C++ compiler inserts the implementation_key compiler directive in the TypeLib Information (TLI) Object Library and in the Type Library Header (TLH) files. The injected code may look similar to the following code:
#pragma start_map_region ("...\Namesp.tli")
 __declspec(implementation_key(1)) <a method prototype>
 __declspec(implementation_key(2)) <a method prototype>
When large numbers of methods are used in the Interface Description Language (IDL) file, the Visual C++ compiler starts to use the #pragma implementation_key compiler directive for each function to improve performance. The #pragma implementation_key compiler directive may cause some side effects, and you may receive the compiler errors in the TLI file that are mentioned in Symptoms section.

RESOLUTION

You can disable the implementation_key compiler directive by adding the undocumented no_function_mapping compiler directive to your #import statement as follows:
#import "Dllname.dll" no_function_mapping
This code removes the #pragma implementation_key compiler directive from the TLI file and resolves the compiler errors.

STATUS

This behavior is by design.

Modification Type:MajorLast Reviewed:1/12/2006
Keywords:kbtshoot kbprb kbCompiler kbDLL kberrmsg kbinfo KB832688 kbAudDeveloper