VC ++ 6.0 MFC应用程序链接到Win32 DLL问题与指向结构的指针 [英] VC++ 6.0 MFC Application linking to a Win32 DLL issue with pointer to a struct

查看:76
本文介绍了VC ++ 6.0 MFC应用程序链接到Win32 DLL问题与指向结构的指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望之前有人见过这个...


我有一个看起来像这样的头文件


typedef struct ATYPE

{

int one;

int two;

char first;

} atype;


typedef struct BTYPE

{

BYTE FIRST;

BYTE第二个;

atype aData [10];

} btype;


我链接的DLL的一些函数也是如此。 ..


在我的代码中我添加了一个成员varable像

public:

btype * array;


当我在声明之后停止执行时我看到了

名称值

& array 0x0012f9e4" III xA"


但是我没看到

数组0x001245ef {...}

| - 第一个0

第二个0


我运行正确的演示应用程序然而当我尝试重新创建代码时,我得到了一个尝试将&数组传递给函数时出现访问冲突......


似乎我错过了某种指令或其他东西,但到目前为止还无法追踪它。 ..


如果有人见过这样的事情,请让我知道......


谢谢!

I''m hoping someone has seen this before ...

I have a header file that looks something like this

typedef struct ATYPE
{
int one;
int two;
char first;
}atype;

typedef struct BTYPE
{
BYTE FIRST;
BYTE SECOND;
atype aData[10];
}btype;

the some functions for the DLL I am linking too...

in my code I add a member varable like
public:
btype *array;

when I stop execution just after that statement I see the
Name Value
&array 0x0012f9e4 "III xA"

but I dont see
array 0x001245ef {...}
|- FIRST 0
SECOND 0

the demo app that I have runs correctly however when I try to recreate the code I get an access violation when trying to pass &array to a function...

it seems I am missing some kind of directive or something but thus far have not been able to track it down...

PLEASE if anyone has seen anything like this before let me know ...

Thank you!

推荐答案

听起来你正在使用指针,而不是通过从堆中为它们指向的数据分配内存来初始化它们。
It sounds like you are using pointers without initialising them by allocating memory from the heap for the data they point to.



听起来你正在使用指针,而不是通过从堆中为它们指向的数据分配内存来初始化指针。
It sounds like you are using pointers without initialising them by allocating memory from the heap for the data they point to.



这听起来确实如此,但即使我将语句改为阅读

typeb array = new typeb;我仍然在MFC42.DLL中遇到相同的访问冲突错误

Thats exactly what it sounds like, however even when I change the statement to read
typeb array = new typeb; I still get the same access violation error in MFC42.DLL


在调试器中运行它,当它崩溃时查看调用堆栈并跟踪调用堆栈以查看是否有任何函数正在使用无效参数调用。然后确定参数无效的原因。
Run it in the debugger and when it crashes look at the call stack and trace up the call stack to see if any of the functions are being called with invalid parameters. Then determin why the parameters are not valid.


这篇关于VC ++ 6.0 MFC应用程序链接到Win32 DLL问题与指向结构的指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆