I am using two ATL/COM component in my VC++ application with the help of following import statement.
#import "First.dll" raw_interfaces_only, raw_native_types, no_namespace, named_guids
#import "Second.dll" raw_interfaces_only named_guids no_namespace no_implementation
First.DLL and Second.DLL have a few repeated declarations. For example, the following enum is declared in both imported DLL files.
enum Collection
{
JAN,
SEPT,
DEC
}
I want to use both DLL but am getting an error like Collection is declared twice. Can someone please guide me to solve this.
You can disambiguate between types of the same name by moving them into distinct namespaces. To do so, remove the no_namespace attribute. If the types aren't declared in a namespace already, you can use the rename_namespace attribute in the #import directive.
As an alternative, you can rename one or both of the colliding type names. This allows you to keep the no_namespace
attribute, and import all types into the global namespace.