P
pikulsky
There is a managed C++ class (ManagedClass) defined in one library
(TestMCpp.dll), it has a method (funcTemplate) with template native
type (NativeTemplate<int>). This library is built without any errors.
There is another managed C++ project (UseTestMCpp) which uses the
ManagedClass class: it does have included header file with native type
definitions but it does not help in case with template parameters.
The explicit instantiation of the template does not help as well.
While building the second project (UseTestMCpp) MS VS .NET 2003
compiler says:
UseTest1.cpp(13) : error C3635: '::NativeTemplate<int>': undefined
native type used in 'ManagedClass'; imported native types must be
defined in the importing source code
did you forget to include a header file?
UseTest1.cpp(13) : error C3377: 'ManagedClass::funcTemplate' : cannot
import method - a parameter type or the return type is inaccessible
Source code:
The first library (TestMCpp.dll):
//--- begin of Test0.h
#ifndef TEST0_H
#define TEST0_H
template <typename X> class NativeTemplate
{
public:
X* pointerX_;
X* nativeTemplateFunction() { return pointerX_; } ;
};
#endif
//--- end of Test0.h
//--- begin of Test1.cpp
#using <mscorlib.dll>
#include "Test0.h"
public __gc class ManagedClass
{
public:
void funcTemplate(NativeTemplate<int> *n) {}
};
//--- end of Test1.cpp
And another managed C++ project:
//--- begin of UseTest1.cpp
#using <mscorlib.dll>
#using "TestMCpp.dll"
#include "../TestMCpp/Test0.h"
int main()
{
ManagedClass *x = new ManagedClass();
}
//--- end of UseTest1.cpp
How could I fix such compiler error?
Thank you in advance,
Valeriy Pikulskyy
P.S. I found a post in "microsoft.public.dotnet.languages.vc" newsgroup
that describes exactly the same issue:
http://groups.google.com/group/microsoft.public.dotnet.languages.vc/msg/fd1425fb4fcbce53
But it's dated by February, 2004, and has no answer.
(TestMCpp.dll), it has a method (funcTemplate) with template native
type (NativeTemplate<int>). This library is built without any errors.
There is another managed C++ project (UseTestMCpp) which uses the
ManagedClass class: it does have included header file with native type
definitions but it does not help in case with template parameters.
The explicit instantiation of the template does not help as well.
While building the second project (UseTestMCpp) MS VS .NET 2003
compiler says:
UseTest1.cpp(13) : error C3635: '::NativeTemplate<int>': undefined
native type used in 'ManagedClass'; imported native types must be
defined in the importing source code
did you forget to include a header file?
UseTest1.cpp(13) : error C3377: 'ManagedClass::funcTemplate' : cannot
import method - a parameter type or the return type is inaccessible
Source code:
The first library (TestMCpp.dll):
//--- begin of Test0.h
#ifndef TEST0_H
#define TEST0_H
template <typename X> class NativeTemplate
{
public:
X* pointerX_;
X* nativeTemplateFunction() { return pointerX_; } ;
};
#endif
//--- end of Test0.h
//--- begin of Test1.cpp
#using <mscorlib.dll>
#include "Test0.h"
public __gc class ManagedClass
{
public:
void funcTemplate(NativeTemplate<int> *n) {}
};
//--- end of Test1.cpp
And another managed C++ project:
//--- begin of UseTest1.cpp
#using <mscorlib.dll>
#using "TestMCpp.dll"
#include "../TestMCpp/Test0.h"
int main()
{
ManagedClass *x = new ManagedClass();
}
//--- end of UseTest1.cpp
How could I fix such compiler error?
Thank you in advance,
Valeriy Pikulskyy
P.S. I found a post in "microsoft.public.dotnet.languages.vc" newsgroup
that describes exactly the same issue:
http://groups.google.com/group/microsoft.public.dotnet.languages.vc/msg/fd1425fb4fcbce53
But it's dated by February, 2004, and has no answer.