Jump to content
  • Advertisement
Sign in to follow this  
Michael Anthony Wion

Stuck at error D8016

This topic is 2284 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

I'll try to keep this as short and simple, yet descriptive as possible...
I've been rewriting a graphics engine in C++ for use in managed VB/C#.
The architecture of the engine also allows for use of unmanaged classes from within C++.
In each class header file, I define the class using the 'declspec dllimport/dllexport' specifiers.

Then underneath the class definition, I define various functions which return/use pointers to these classes, allowing manipulation of class members from across the threshold of managed code.
These functions are defined using __stdcall and __clrcall, with respect to whether or not the parameters contain managed objects (i.e., 'myclass *__stdcall initclass(char *mystring)' versus 'myclass *__clrcall initclass(System::String ^mystring)').
Then, these methods are exported using a .DEF file, so that they can be accessed in VB/C# via the <DllImport> attribute.
Pretty standard mixed-mode DLL stuff, here.

So with the way that this is set up, I most definitely can't get around having to use the '/clr' compiler option when building the DLL.
But after I finished writing out all of the class definitions & implementations, it was time to create a class that could hold a collection of these objects.
The first thought in my mind was to use the stl::vector class to handle this, since I'm not sure how to efficiently manage several C arrays holding valid pointers to various objects (i.e., how to 'remove' an element and resize the array without effecting the validity of existing objects).


Guess what? BAM!!

[font=arial,helvetica,sans-serif]warning C4251: '' : class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class ''[/font]

Okay, no big deal. I do a little research and find this:
http://www.gamedev.n...ients-of-class/
... which points to the fix, shown here: http://support.microsoft.com/kb/168958
... which, in the example, shows that the dll needs to be compiled using the following compiler flags: /GX /LDd /MDd /D"EXP_STL"
Okay, also no big deal. I update my code, set the compiler flags, hit rebuild, and BAM!!!

[font=arial,helvetica,sans-serif]error D8016: '/clr' and '/GX' command-line options are incompatible[/font]

Dude, wtf!? And if I omit the '/GX' option, and get 28 errors and 6 warnings, all of which are random syntax errors, pointing to random places in both my header and implementation files where the code was working flawlessly before I tried to add vectors.
How can I get around this? Is there a better, unmanaged way to manage a collection of objects, without resorting to some sort of hacking and dancing around compiler errors?
I'm open to any and all ideas.

Free beer to the first who can help me solve this. And by beer, I actually mean love.
Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
For some reason I always manage to find a solution not long after posting about it, no matter how long I spend trying to solve it beforehand.
I've now been able to compile the DLL, using vectors, but I still get a dozen C4251 warnings. When tested in VB and C#, there doesn't appear to be any errors...
So I just disabled the warning in my project settings. But I'm curious if there's an actual resolution to this, and if perhaps there might be unforseen problems with ignoring the errors. If anyone knows, please share!

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!