我在有EVC建立一个dll时,用的是WINCE Dynamic-Link Liabrary选项,然后加入类如下:
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers#include <afxwin.h> // MFC core and standard components//标准模板库和标准收集动态数据分配
#ifndef _AFX_STEMPL_COLL
#define _AFX_STEMPL_COLL
#include <afxtempl.h>
#include <afxcoll.h>
#include "math.h"
#endif//该头文件定义图像处理宏:#ifndef __m3d_h_
#ifndef __M3D_H_#define __m3d_h_
#define __M3D_H_#ifdef __cplusplus
extern "C" {
/////////////////////////////////////////////////////////////////////////////////
//
// interface for the CVertex3d class.
//
////////////////////////////////////////////////////////////////////////////////
//has included afxcoll.h in the stdafx.h
class __declspec(dllexport) CVertex3d
{
public:
CVertex3d();
CVertex3d(const CVertex3d& vSrc);
virtual ~CVertex3d();public:
CVertex3d operator = (const CVertex3d& vSrc); void DefineTopology(const int* pnInFacet, int nNumFacet);public:
CArray <int,int> m_asIndex;
};
然后编写相应的CPP文件,出现warning如下:
warning C4251: 'm_asIndex' : class 'CArray<int,int>' needs to have dll-interface to be used by clients of class 'CVertex3d'libli
并生成lib和dll文件。生成后新建新工程来引用 库中的类,但是当引用类成员
m_asIndex并向其中增加一个成员时,出现异常,如下:
unhandled exception in xx.exe:0xc00000005 :Access Violation.对于此问题我是刚摸dll,还请各们大侠指教,定当高分送上,谢谢!!!!!
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers#include <afxwin.h> // MFC core and standard components//标准模板库和标准收集动态数据分配
#ifndef _AFX_STEMPL_COLL
#define _AFX_STEMPL_COLL
#include <afxtempl.h>
#include <afxcoll.h>
#include "math.h"
#endif//该头文件定义图像处理宏:#ifndef __m3d_h_
#ifndef __M3D_H_#define __m3d_h_
#define __M3D_H_#ifdef __cplusplus
extern "C" {
/////////////////////////////////////////////////////////////////////////////////
//
// interface for the CVertex3d class.
//
////////////////////////////////////////////////////////////////////////////////
//has included afxcoll.h in the stdafx.h
class __declspec(dllexport) CVertex3d
{
public:
CVertex3d();
CVertex3d(const CVertex3d& vSrc);
virtual ~CVertex3d();public:
CVertex3d operator = (const CVertex3d& vSrc); void DefineTopology(const int* pnInFacet, int nNumFacet);public:
CArray <int,int> m_asIndex;
};
然后编写相应的CPP文件,出现warning如下:
warning C4251: 'm_asIndex' : class 'CArray<int,int>' needs to have dll-interface to be used by clients of class 'CVertex3d'libli
并生成lib和dll文件。生成后新建新工程来引用 库中的类,但是当引用类成员
m_asIndex并向其中增加一个成员时,出现异常,如下:
unhandled exception in xx.exe:0xc00000005 :Access Violation.对于此问题我是刚摸dll,还请各们大侠指教,定当高分送上,谢谢!!!!!
解决方案 »
- 16位颜色质量下怎么截屏取到24位的位图?(vc)
- 画图的问题
- 关于安装Office2007后,使用Visual Studio 2008 Sp1 创建的带有Office Fluent风格程序时字体变动
- 不用菜单按钮,怎么给工具栏按钮直接添加消息??
- 当鼠标移动到一个按钮上面的时候,请问怎么改变光标的形状?
- 编译连接问题:我编译通过了,连接时出现LINK1168号错误,不能打开DEBUG\AAA.EXE文件,以只读方式.请指点.
- 向高手请教:ActiveMovie控件播放视频的问题
- bcb和vc那个好??
- 界面线程切换比较慢慢
- 我想知道dyStyle,dwCtrlStyle的全部列表,告诉我它在msdn里的具体位置也可以
- 开发的运用程序.编译时没错,但运行就有非法操作,这一般是什么问题!!
- 请教一个函数?
Knowledge Base Articles PRB: C4251 & C4275 Compiler Warnings While Compiling an AFXDLL
Q134980
--------------------------------------------------------------------------------
The information in this article applies to:The Microsoft Foundation Classes (MFC), used with:
Microsoft Visual C++, 32-bit Editions, versions 2.0, 2.1, 2.2--------------------------------------------------------------------------------
SYMPTOMS
The Compiler issues the following warning for a class derived from one of the MFC classes: warning C4275: non dll-interface class <XXX> used as base for dll-interface class <YYY>
A related warning is issued when an object of some MFC class is embedded as a data member of a user-defined class:
warning C4251: <identifier> : class <XXX> needs to have dll-interface to be used by clients of class <YYY>
See the "Sample Code" section of this article an example of a class declaration that generates these warnings.This problem no longer occurs in vc 4.0 or later. CAUSE
The DLL version of MFC does not export its classes by declaring them with "class __declspec(dllexport)." Instead, it exports its classes through entries in the EXPORTS section of its module definition (.def) file.Because the compiler has only the header files to work with, it cannot determine whether the MFC classes were actually exported, and therefore it issues the warning. RESOLUTION
Because the MFC classes are in fact exported, these warnings can be safely ignored. As shown in the DLLHUSK sample, you can disable these warnings by using the following pragma statements:
#pragma warning(disable: 4275)
#pragma warning(disable: 4251)
On the other hand, if the warnings refer to some user-defined class rather an MFC class, you should ensure that the class is exported before disabling these warnings. STATUS
This behavior is by design. MORE INFORMATIONSample Code to Reproduce Behavior/* Compile options needed: None
*/ // The following class declaration causes a C4275 warning
// because the CObject class is not also declared with
// __declspec(dllexport).
class __declspec(dllexport) CMyClass : public CObject
{
...
// The following data member causes a C4251 warning,
// because the CString class is not declared with
// __declspec(dllexport).
CString m_strName;
...
}; REFERENCES
For more information, please see MFC TechNote 33 for a discussion of the reasons behind the decision to export MFC's classes in the module definition file rather than in the class declaration. Additional query words: 2.00 2.10 2.20 3.00 3.10 3.20 Keywords : kberrmsg kbnokeyword kbDLL kbMFC kbVC200 kbVC220 kbGrpDSMFCATL
Issue type : kbprb
Technology : kbAudDeveloper kbMFC
Last Reviewed: May 6, 2001--------------------------------------------------------------------------------Send feedback to Microsoft© 2002 Microsoft Corporation. All rights reserved.