Jump to content
  • Advertisement
Sign in to follow this  
The_Grand_User

[.net] Managed C++/CLR DLLs sharing native C++ structs

This topic is 3258 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm wondering if it's possible for two C++/CLR Dlls to share/pass native structs (like a D3DXVECTOR3). I've got something similar to the fllowing (where the second DLL has the first as a refernce):
// DLL1.h/cpp
namespace DLL1
{
  public class class1
  {
     public: static float Foo(D3DXVECTOR3 vec) { ... }
  } 
}

// DLL2.h/cpp
namespace DLL2
{
  public class class2
  {
     public: void Bar()
     {
        D3DXVECTOR3 avec = ...
        ...
        float result = DLL1::class1::Foo(avec);
        ...
     }
  } 
}

However, I'm getting a "error C3767: 'DLL1::class1::Foo': candidate function(s) not accessible" So is it just not possible to do this or am I missing something? And if it's not possible, what's the recomended way around it? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
By default, native types do not have public accessibility any longer. This means that while your function Foo is public, it depends on an internal type D3DXVECTOR3 and is thus not accessible.

You can use the make_public pragma to force the D3DXVECTOR3 type to be public, or you can have the assemblies in question friend eachother via the InternalsVisibleTo attribute. Neither of these are terribly elegant, unfortunately.

A better option might be to wrap the native structure in question so that it is more cleanly exposed beyond your assembly.

(Also, it's C++/CLI, technically, not C++/CLR.)

Share this post


Link to post
Share on other sites
Thanks, it's working nicely now :)

I'm going to try to avoid wrapping the stucts for now, until I can check the performance differences at least.

(@C++/Cli ... I knew that, just thinking of other things I guess)

Again, thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!