R
rob
I have two projects (dlltest, dll2) both creating a dll. The two dlls
define classes (dll1, dll2) within the same namespace (MyNamespace).
One of the dlls (dlltest) is using functionality of the other dll
(dll2). Also both dlls use the same enum (MyEnum) defined in a header
file (common.h). This header file is included in both dlls.
Now I have one function from the first dll (dlltest) return the return
argument from the second dll (dll2). The compiler then complains:
error C2440: 'return' : cannot convert 'MyNamespace::MyEnum' to
'MyNamespace::MyEnum'.
It seems that because the include file is included in both dlls MyEnum
is considered as two different enums even if they reside in the same
namespace. Is this correct? If so then how can it distinguish between
the two if they are called the same? If not then what is the problem.
In any case, what is the proper solution to this? Maybe I could combine
everything in one dll but the functionality of dll2 really can stand on
it's own feet so throwing dlltest into the dll2 does not seem proper.
Also in the actual project there are other dlls that can live
bythemselves but they have some common types. So I am really not sure
how to solve this problem (technically and conceptually). Any ideas are
welcome.
common.h
---------
#ifndef _COMMON_H
#define _COMMON_H
enum class MyEnum{
enum1,
enum2,
enum3
};
#endif
dll2
---
using namespace System;
namespace MyNamespace{
#include "../dlltest/common.h"
public ref class dll2{
public:
static MyEnum ReturnEnumDll2(){
return MyEnum::enum1;
}
};
}
dlltest
------
using namespace System;
#using <dll2.dll>
namespace MyNamespace {
#include "common.h"
public ref class dll1 {
MyEnum ReturnEnumDll1(){
return dll2::ReturnEnumDll2();
}
};
}
Regards,
Rob
define classes (dll1, dll2) within the same namespace (MyNamespace).
One of the dlls (dlltest) is using functionality of the other dll
(dll2). Also both dlls use the same enum (MyEnum) defined in a header
file (common.h). This header file is included in both dlls.
Now I have one function from the first dll (dlltest) return the return
argument from the second dll (dll2). The compiler then complains:
error C2440: 'return' : cannot convert 'MyNamespace::MyEnum' to
'MyNamespace::MyEnum'.
It seems that because the include file is included in both dlls MyEnum
is considered as two different enums even if they reside in the same
namespace. Is this correct? If so then how can it distinguish between
the two if they are called the same? If not then what is the problem.
In any case, what is the proper solution to this? Maybe I could combine
everything in one dll but the functionality of dll2 really can stand on
it's own feet so throwing dlltest into the dll2 does not seem proper.
Also in the actual project there are other dlls that can live
bythemselves but they have some common types. So I am really not sure
how to solve this problem (technically and conceptually). Any ideas are
welcome.
common.h
---------
#ifndef _COMMON_H
#define _COMMON_H
enum class MyEnum{
enum1,
enum2,
enum3
};
#endif
dll2
---
using namespace System;
namespace MyNamespace{
#include "../dlltest/common.h"
public ref class dll2{
public:
static MyEnum ReturnEnumDll2(){
return MyEnum::enum1;
}
};
}
dlltest
------
using namespace System;
#using <dll2.dll>
namespace MyNamespace {
#include "common.h"
public ref class dll1 {
MyEnum ReturnEnumDll1(){
return dll2::ReturnEnumDll2();
}
};
}
Regards,
Rob