Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 636
  • Last Modified:

Problems with Window class

Hello,

I have a problem with a CWindow class I use in a DLL. I load the class from the DLL.
The compile throws a message, and I am sure this is a problem of some crashes, too.
So anybody can give me a hint what is wrong here?

Ocrana

Compileroutput:
1>c:\projects\dvdranger2\trunk\dvdconvdll\mediawnd.h(120) : warning C4275: non dll-interface class 'ATL::CWindow' used as base for dll-interface class 'ATL::CWindowImplRoot<TBase>'
1>        with
1>        [
1>            TBase=ATL::CWindow
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\atlmfc\include\atlwin.h(686) : see declaration of 'ATL::CWindow'
1>c:\projects\dvdranger2\trunk\dvdconvdll\mediawnd.h(289) : warning C4251: 'MediaWnd::frameBuffers' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'MediaWnd'
1>        with
1>        [
1>            _Ty=BYTE *
1>        ]
#pragma once
#ifdef MOBILE_CONV_DLL
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllimport)
#endif

#include <atlbase.h>
#include <atlctl.h>
#include <list>

class DLLEXPORT MediaWnd : public CWindowImpl<MediaWnd, CWindow>
{
	BEGIN_MSG_MAP(MediaWnd)
		DEFAULT_REFLECTION_HANDLER()
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
		....
	END_MSG_MAP()

public:
	MediaWnd();
	virtual ~MediaWnd();

	virtual void CreateWnd(HWND hWnd);
	....
	std::list<BYTE *> frameBuffers;
	....
	
}

Open in new window

0
Ocrana
Asked:
Ocrana
  • 2
1 Solution
 
jkrCommented:
You are hitting a mine field here - see http://support.microsoft.com/kb/168958 ("How to export an instantiation of a Standard Template Library (STL) class and a class that contains a data member that is an STL object"). In short: Don't make an STL object publicly accessible in a DLL, always use accessors that conceal the object, e.g.
#pragma once
#ifdef MOBILE_CONV_DLL
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllimport)
#endif

#include <atlbase.h>
#include <atlctl.h>
#include <list>

class DLLEXPORT MediaWnd : public CWindowImpl<MediaWnd, CWindow>
{
	BEGIN_MSG_MAP(MediaWnd)
		DEFAULT_REFLECTION_HANDLER()
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
		....
	END_MSG_MAP()

public:
	MediaWnd();
	virtual ~MediaWnd();

	virtual void CreateWnd(HWND hWnd);
	....

        BYTE* GetNextFrame() { */ ... */ }

protected:
	std::list<BYTE *> frameBuffers;
	....
	
}

Open in new window

0
 
OcranaAuthor Commented:
Hi,

I have set it to protected but the compiler is still naging with the same issue. So no change there.

Ocrana
0
 
sarabandeCommented:
the std::list<BYTE*> cannot exported/imported between dll boundaries (at least not without efforts).

so you may think of using array of BYTE* instead.

Sara
0
 
OcranaAuthor Commented:
I use the std:list<BYTE*> for internal use.It is portected now. It contains the rendering buffer for the MEdiaWnd (a set of images). A "simple" Byte Arry is the worst solution.But why the compile see a protected member as a export one? It is not public, so not available to the export.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now