Select to view content in your preferred language

ArcObjects C++: #import order problems

795
1
Jump to solution
10-31-2013 04:26 AM
Andreas_W_Paulsen
Occasional Contributor
I am having a lot of problems with the #import of ESRI C++ libraries.
I am using precompiled headers:
stdafx.h:
#import <esriSystem.olb> raw_interfaces_only, raw_native_types, no_namespace, named_guids, auto_search , exclude("OLE_COLOR", "OLE_HANDLE", "VARTYPE") #import <esriSystemUI.olb> raw_interfaces_only, raw_native_types, no_namespace, named_guids, auto_search, exclude("IProgressDialog") // ...


The import order seem to be very important. Thing may work fine and then I add a new class where I need to use a new ESRI library and BOOM, I get a lot of strange compilation errors.

One common source of problems are interfaces that occur in both windows system libraries and ESRI libraries. For instance I might get a compilation error complaining about esriFramework::IPropertyPage not being defined. When I look trough the CC output I note that this was automatically excluded when importing the esriFramework.olb.

Any advice on how to prevent such problems?
0 Kudos
1 Solution

Accepted Solutions
RichardWatson
Deactivated User
Importing ESRI type libraries in C++ is painful because you have to take care to import any dependencies first.  This is not required when defining the type library itself, i.e. in the IDL.  It is also painful because of namespace/type collisions so you have to come up with the correct set of magic words needed to make this work.

The best advice that I have is to look at the ESRI samples.

View solution in original post

0 Kudos
1 Reply
RichardWatson
Deactivated User
Importing ESRI type libraries in C++ is painful because you have to take care to import any dependencies first.  This is not required when defining the type library itself, i.e. in the IDL.  It is also painful because of namespace/type collisions so you have to come up with the correct set of magic words needed to make this work.

The best advice that I have is to look at the ESRI samples.
0 Kudos