?
Solved

Clarification around #import attributes

Posted on 2009-04-15
8
Medium Priority
?
336 Views
Last Modified: 2012-05-06
Given the following attributes that are commonly attached to the #import statement:

no_implementation
no_namespace
raw_interfaces_only
raw_native_types
named_guids

Can anyone clarify in what circumstances you would apply these attributes and those you wouldn't?  Many thanks.
0
Comment
Question by:Alburns
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
8 Comments
 
LVL 40

Expert Comment

by:evilrix
ID: 24145829
C/C++ Preprocessor Reference
#import Attributes
http://msdn.microsoft.com/en-us/library/298h7faa.aspx

auto_rename
 Renames C++ reserved words by appending two underscores (__) to the variable name to resolve potential name conflicts.
 
auto_search
 Specifies that, when a type library is referenced with #import and itself references another type library, the compiler can do an implicit #import for the other type library.
 
embedded_idl
 Specifies that the type library is written to the .tlh file with the attribute-generated code preserved.
 
exclude (#import)
 Excludes items from the type library header files being generated.
 
high_method_prefix
 Specifies a prefix to be used in naming high-level properties and methods.
 
high_property_prefixes
 Specifies alternate prefixes for three property methods.
 
implementation_only
 Suppresses the generation of the .tlh header file (the primary header file).
 
include()
 Disables automatic exclusion.
 
inject_statement
 Inserts its argument as source text into the type-library header.
 
named_guids
 Tells the compiler to define and initialize GUID variables in old style, of the form LIBID_MyLib, CLSID_MyCoClass, IID_MyInterface, and DIID_MyDispInterface.
 
no_auto_exclude
 Disables automatic exclusion.
 
no_dual_interfaces
 Changes the way the compiler generates wrapper functions for dual interface methods.
 
no_implementation
 Suppresses the generation of the .tli header, which contains the implementations of the wrapper member functions.
 
no_namespace
 Specifies that the namespace name is not generated by the compiler.
 
no_registry
 Tells the compiler not to search the registry for type libraries.
 
no_search_namespace
 Has the same functionality as the no_namespace attribute but is used on type libraries that you use the #import directive with the auto_search attribute.
 
no_smart_pointers
 Suppresses the creation of smart pointers for all interfaces in the type library.
 
raw_dispinterfaces
 Tells the compiler to generate low-level wrapper functions for dispinterface methods and properties that call IDispatch::Invoke and return the HRESULT error code.
 
raw_interfaces_only
 Suppresses the generation of error-handling wrapper functions and property (C++) declarations that use those wrapper functions.
 
raw_method_prefix
 Specifies a different prefix to avoid name collisions.
 
raw_native_types
 Disables the use of COM support classes in the high-level wrapper functions and forces the use of low-level data types instead.
 
raw_property_prefixes
 Specifies alternate prefixes for three property methods.
 
rename (#import)
 Works around name collision problems.
 
rename_namespace
 Renames the namespace that contains the contents of the type library.
 
rename_search_namespace
 Has the same functionality as the rename_namespace attribute but is used on type libraries that you use the #import directive with the auto_search attribute.
 
tlbid
 Allows for loading libraries other than the primary type library.
 
0
 
LVL 40

Expert Comment

by:evilrix
ID: 24145832
^^^incidentally, the above info is for your reference and does not suppose to answer your question :)
0
 

Author Comment

by:Alburns
ID: 24145857
Thanks for the response.  Yes, I found this in MSDN but wasn't particularly helpful as I really needed some general advice on when you would apply these attributes and when you wouldn't.
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 150 total points
ID: 24343233
The #import handler in the complier does a lot of complex stuff.  Those attributes control some the less-used options.   A bit of experimentation would show, for instance, that raw_interfaces_only generates somewhat different code in the resulting .TLH header file.
Basically, if you don't know what the attribute does, you almost certainly don't need to use it.
0
 

Author Closing Comment

by:Alburns
ID: 31570325
Many thanks for your reply.  I'll have a play around with these attributes and try to figure out what effect they have.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Starting up a Project
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question