-*****动态链接库的问题******-

MeKing 2002-11-05 09:56:53
我在有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,还请各们大侠指教,定当高分送上,谢谢!!!!!



...全文
160 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuefl66 2002-11-06
  • 打赏
  • 举报
回复
see
see

MeKing 2002-11-06
  • 打赏
  • 举报
回复
不过这虽然知道了原因,但还是不知如何去解决它,我知道因为dll文件与exe文件的区别在于前者没有堆栈,而在进行动态分配内存进都是在堆栈中分配的。而上面的程序的CArray是要动态分配内存的,是不是因为这个才出错的???,以上是我的理解????不知各们有没有更好的意见????
ruihuahan 2002-11-06
  • 打赏
  • 举报
回复
up
zhang865 2002-11-06
  • 打赏
  • 举报
回复
没有搞过WINCE。
MeKing 2002-11-05
  • 打赏
  • 举报
回复
自己找到


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 INFORMATION

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


ylb_and_xy 2002-11-05
  • 打赏
  • 举报
回复
不知道,UP一下。
MeKing 2002-11-05
  • 打赏
  • 举报
回复
没人啊,我着急啊
frued 2002-11-05
  • 打赏
  • 举报
回复
呵呵,这样多好,强,佩服。
up一下
标题人事档案管理系统设计与实现研究AI更换标题第1章引言介绍人事档案管理系统的研究背景、意义、国内外研究现状以及论文的方法和创新点。1.1研究背景与意义分析人事档案管理在企业中的重要性及系统开发的必要性。1.2国内外研究现状概述国内外人事档案管理系统的研究进展和现状。1.3研究方法及创新点阐述本文的研究方法和在系统设计上的创新点。第2章相关理论介绍人事档案管理系统设计的相关理论。2.1档案管理理论阐述档案分类、存储、检索等基本理论。2.2信息系统开发理论介绍信息系统开发的基本流程、方法和技术。2.3数据库管理理论讨论数据库设计、数据安全与备份等理论。第3章人事档案管理系统设计详细介绍人事档案管理系统的设计方案和实现过程。3.1系统需求分析分析系统的功能需求、性能需求和用户需求。3.2系统架构设计给出系统的整体架构、模块划分和交互流程。3.3数据库设计设计数据库结构,包括表结构、字段设置和关系模型。第4章系统实现与测试阐述人事档案管理系统的实现过程和测试方法。4.1系统开发环境与工具介绍系统开发所使用的环境和工具。4.2系统实现过程详细描述系统各个模块的实现过程和关键代码。4.3系统测试与优化对系统进行功能测试、性能测试和安全测试,并进行优化。第5章研究结果与分析呈现人事档案管理系统的实验分析结果。5.1系统功能实现情况介绍系统各项功能的实现情况和效果。5.2系统性能评估从响应时间、吞吐量等指标评估系统性能。5.3对比方法分析将本系统与其他类似系统进行对比分析,突出优势。第6章结论与展望总结本文的研究成果,并展望未来的研究方向。6.1研究结论概括本文的主要研究结论和系统实现效果。6.2展望指出系统存在的不足和未来改进的方向。
提供了关于时间序列分析与预测的宝贵资源,特别聚焦于**自回归积分滑动平均模型(ARIMA)**及其应用。对于那些希望深入理解并实践时间序列建模的学者、研究人员以及数据分析爱好者来说,这是一个不可或缺的学习材料。本资源不仅包括了详细的理论讲解,涵盖了时间序列分析的基础,如移动平均(MA)、自回归(AR)、指数平滑等关键概念,而且通过具体的ARIMA模型解析,搭配MATLAB编程实现实例,帮助用户从理论到实践全面掌握这一重要统计工具。 内容概览 理论讲解: 深入浅出地介绍了时间序列分析的基本原理,重点阐述ARIMA模型的构建步骤,包括如何识别模型的参数(p,d,q),以及其在处理非平稳数据中的作用。 MATLAB代码实现: 提供了多个ARIMA模型的MATLAB实现示例,这些代码覆盖了从数据准备、模型拟合、诊断检验到预测的全过程,是学习如何利用MATLAB进行时间序列分析的实用工具。 实例分析: 包括不同行业或领域的实际案例研究,展示如何应用ARIMA及其它时间序列方法解决真实世界的数据预测问题,增强理解和应用能力。 文件结构 时间序列模型ARIMA的讲解与matlab代码实现(含多个实例).rar: 主要资源压缩包,解压后包含文档和MATLAB代码文件夹。 文档: 提供了理论知识讲解。 MATLAB代码: 实现了文中讨论的各种模型,附带注释,便于理解与修改。 使用指南 下载资源: 点击下载“时间序列模型ARIMA的讲解与matlab代码实现(含多个实例).rar”文件。 解压文件: 解压缩至本地,确保你可以访问文档和代码。 环境准备: 确保你的电脑上已安装MATLAB,并熟悉基本操作。 学习流程: 首先阅读文档理解时间序列分析的理论基础,然后逐步跟随MATLAB代码示例进行实践。 实践应用: 尝试将所学应用到自己的数据集上,调整参数以优化模型性能。 注意事项 请根据M

15,467

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧