C3635/C3377 errors while using managed class with template parameter from another library

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.
 
B

Ben Voigt

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

There aren't 13 lines in the UseTest1.cpp you posted. Can you indicate
which line this error message is triggered on?

Is it possible for you to try this on C++/CLI? (download Visual C++ 2005
Express if you don't have Studio 2005) An awful lot of stuff got an awful
lot easier in the new version.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top