Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] Strange C3767 error and constructor inheritance

Started by paic Nov 3, 2008 at 5:07 AM 2 replies 2.4k views
Original Post
paic
paic
Hi, I just came across a strange error, and I'd like some advice about it. I have the following classes :

public ref class IEntity : public System::Windows::Forms::UserControl
{
public:   IEntity(void);                 // default constructor for the designer
public:   IEntity(MDagPath * dagPath);   // the constructor I need

// the rest of the class (don't think it's useful for my problem)
};

public ref class Mesh : public IEntity
{
public:  Mesh(void);
public:  Mesh(MDagPath * dagPath) : IEntity(dagPath)  { }
};




When I compile, I get the following error : error C3767: 'IEntity::IEntity': candidate function(s) not accessible. (This error is reported for the Mesh::Mesh(MDagPath *) constructor) Well, I don't really understand why ... I used this kind of constructor inheritance multiple times in the past, and it always worked ... And the strangest part is that the following code compiles without any problem :

public ref class IEntity : public System::Windows::Forms::UserControl
{

public:   IEntity(void);
public:   IEntity(void * dagPath);
};

public ref class Mesh : public IEntity
{
public:  Mesh(void);
public:  Mesh(void * dagPath) : IEntity(dagPath) {}
};




I just changed the pointer to void * instead of MDagPath * (I typecast it inside the IEntity constructor) And now I don't have the error, it compiles, and run. Why is that ??? What's the difference between MDagPath * and void * ???? For the moment, I'll go with the void * solution, but I would really really like to know what's happening here. So if you have an idea ... :)
remigius
remigius

Without any knowledge about C++/CLI, I'd guess that the access modifier for MDagPath is preventing it from being used in the subclass constructor. Perhaps it's a private or internal class/struct? After a quick search I also found this which may be of use to you:

Quote:
C3767 may also be caused by a breaking change: native types are now private by default in a /clr compilation;

...

Another thing that seems to generate this error is using a native type in the signature of a public method, and then trying to call that method from a different assembly.

The solution here is to add a #pragma make_public on the native type, after defining the native type but before defining the managed method that uses it. The docs for #pragma make_public imply you're supposed to get a compiler warning when a non-public native type is exposed by a public managed type, but (at least with the default warning levels) that does not seem to be the case.


Good luck at any rate!
Magos
Magos
Assuming MDagPath is a managed class, use "MDagPath^ dagPath" instead of "MDagPath* dagPath". If it's an unmanaged class I don't think you can use it publicly.
----------------------------------------MagosX.com
paic
paic
Magos: it's not a managed class, and I've used this kind of constructor in the past without any problem. I could even use a reference : IEntity::IEntity(MDagPath &) So the problem comes from something else :)

Thanks remigius. I used the local MSDN, so I didn't have the user comment at the end of the page you linked.

Now I have this :

#include <maya/MDagPath.h>#pragma make_public(MDagPath)public ref class IEntity : public System::Windows::Forms::UserControl{public:   IEntity(void);                 // default constructor for the designerpublic:   IEntity(MDagPath & dagPath);   // the constructor I need// the rest of the class (don't think it's useful for my problem)};public ref class Mesh : public IEntity{public:  Mesh(void);public:  Mesh(MDagPath & dagPath) : IEntity(dagPath)  { }};


And it works perfectly :) Thanks a lot !
(IEntity was compiled as a separate assembly, which is exactly the problem described in the comment, and the #pragma make_public worked like a charm)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.