471,123 Members | 855 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,123 software developers and data experts.

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


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 Xclass 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/micro...1425fb4fcbce53
But it's dated by February, 2004, and has no answer.

Oct 4 '06 #1
1 1386
>
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.
>
Source code:
The first library (TestMCpp.dll):
//--- begin of Test0.h
#ifndef TEST0_H
#define TEST0_H

template <typename Xclass 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/micro...1425fb4fcbce53
But it's dated by February, 2004, and has no answer.

Oct 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Johan Bergman | last post: by
7 posts views Thread by Lionel B | last post: by
7 posts views Thread by Kristof Thys via .NET 247 | last post: by
1 post views Thread by =?Utf-8?B?SmltIFdhbHNo?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.