Jump to content
  • Advertisement
Sign in to follow this  
3dmodelerguy

DLL and class error

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

ok here is my code for my class inside my dll project:
#include <fstream>
#include "Platform/BaseTypes.h"
#include "Platform/SharedLibraryDefines.h"

#ifndef FILELOGGER_H
#define FILELOGGER_H

#include "Platform/BaseTypes.h"
#include "Platform/SharedLibraryDefines.h"
#include "Message/Log.h"
#include <map>
#include <fstream>

namespace NMessage
{
	class SHAREDLIBRARY CLogManager
	{
		public:
			CLogManager();
			~CLogManager();
			void CreateLog( const NTypes::int8 * log_name, NMessage::CLog * new_log );

		private:
			std::map< const NTypes::int8 *, CLog * > _log_map;
	};
}
#endif

and the SHAREDLIBRARY is defined as: #define SHAREDLIBRARY __declspec( dllexport ) and the warning i am getting is this: s:\Source\Engine\Message\LogManager.h(31) : warning C4251: 'NMessage::CLogManager::_log_map' : class '_STL::map<_Key,_Tp>' needs to have dll-interface to be used by clients of class 'NMessage::CLogManager' what does it mean by need dll-interface to be used by clients of CLogManager? i mean i have another class inside this project with other variable like std::ofstream _log_file; const NTypes::int8 * log_time; time_t rawtime; struct tm * timeinfo; and i don't get this error on them. any help would be greta, i a new to work with dll's. plus if this help i am only statically linking them.

Share this post


Link to post
Share on other sites
Advertisement
I think you're relatively safe to ignore the warning. However, you should be VERY cautios(spelling?) if you're exporting STL classes from the DLL(Such as a function that returns the std::map).

The reason you can't return STL objects should be obvious. Anyone using a different STL version will have either strange results or just plain crashes.

If you take a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/C4251.asp you'll see what the warning means:

Quote:

'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.


In other words, you cannot export std::map from the DLL.

Toolmaker

Share this post


Link to post
Share on other sites
yea i finish creating the log stuff and tested it all out and evrything work fine, so those error don't really matter but i will see if my programming partner can get rid of those if possiable.

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!