Skip to content

Latest commit

 

History

History
100 lines (84 loc) · 2.75 KB

File metadata and controls

100 lines (84 loc) · 2.75 KB
title import | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-windows
ms.tgt_pltfrm
ms.topic language-reference
f1_keywords
vc-attr.import
dev_langs
C++
helpviewer_keywords
import attribute
ms.assetid ebf07cae-39fb-4047-8b57-54af0a9a83de
caps.latest.revision 9
author mikeblome
ms.author mblome
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

import

Specifies another .idl, .odl, or header file containing definitions you want to reference from your main IDL.

Syntax

  
      [ import(  
   idl_file  
) ];  

Parameters

idl_file
The name of an .idl file that you want imported into the type library of the current project.

Remarks

The import C++ attribute causes an #import statement to be placed below the import "docobj.idl" statement in the generated .idl file. The import attribute has the same functionality as the import MIDL attribute.

The import attribute only places the specified file into the .idl file that will be generated by your project; the import attribute does not let you call constructs in the specified file from source code in your project. To call constructs in the specified file from source code in your project, either use #import and the embedded_idl attribute or you can include the .h file for the idl_file, if a .h file exists.

Example

The following code:

// cpp_attr_ref_import.cpp  
// compile with: /LD  
[module(name="MyLib")];  
[import(import.idl)];  

produces the following code in the generated .idl file:

import "docobj.idl";  
import "import.idl";  
  
[ uuid(EED3644C-8488-3ECD-BA97-147DB3CDB499), version(1.0) ]  
library MyLib {  
   importlib("stdole2.tlb");  
   importlib("olepro32.dll");  
...  

Requirements

Attribute Context

Applies to Anywhere
Repeatable No
Required attributes None
Invalid attributes None

For more information, see Attribute Contexts.

See Also

IDL Attributes
Stand-Alone Attributes
importidl
importlib
include
includelib