Jump to content
  • Advertisement
Sign in to follow this  
Keba

DLL exporting warning/issue

This topic is 4767 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, could someone please explain this warning for me: e:\DLL\stdDLLtest\main.cpp(9) : warning C4251: 'CTest::m_Data' : class 'std::vector<_Ty,_Ax>' needs to have dll-interface to be used by clients of class 'CTest' with [ _Ty=int, _Ax=std::allocator<int> ] here's the code:

#include <stdio.h>
#include <vector>

#define DLLEXPORT __declspec(dllexport) 

class DLLEXPORT CTest
{
public:
	std::vector<int> m_Data;
};


void main()
{

}

looked in msdn and found: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' A base class or structure must be declared with the __declspec(dllexport) keyword for a function in a derived class to be exported. does this mean that i have to "export" std::vector? and if so is that possible? thanks!

Share this post


Link to post
Share on other sites
Advertisement
I don't have any experience with MS visual C++
But don't have to create a new project for creating DLL.

and also don't forget to use "dllimport"

Share this post


Link to post
Share on other sites
Quote:
Original post by R3dKnight
But don't have to create a new project for creating DLL.


What do you mean by that? that i have to create a DLL project?

Quote:
and also don't forget to use "dllimport"

this was just a test application do demonstreat the export part, i don't think thats the issue here....or?

Share this post


Link to post
Share on other sites
Because the parameters to a template based class used by external applications are unknown at compile time of the DLL it is impractical (and near impossible) to export the template class. This means you need to create a specific type declaration of the template in order for it to be exported:

__declspec(dllexport) typedef templateclass<param1, param2> exportedType;


Share this post


Link to post
Share on other sites
you mean in this case:


__declspec(dllexport) typedef std::vector<int> myintvector


?...and then:


class DLLEXPORT CTest
{
public:
myintvector m_Data;
};



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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!