一段时间以来,我一直试图找到解决以下问题的方法,但没有成功:
- 我有一个“c” dll,其中定义了以下结构:
文件:myDll.h
#ifdef EXPORTS
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __declspec(dllimport)
#endif
EXPORT struct my_test
{
unsigned char dum0000001[2144];
int test1[32];
unsigned char test2[32];
} test;
在我的 c++ 可执行文件中,我包含了 myDll.h 文件并尝试修改 test1 和 test2:
extern "C"
{
#include "myDll.h"
}
int main(int argc, char** argv)
{
test.test1[0] = 0;
test.test2[0] = 0;
}
程序正确通过:
test.test1[0] = 0;
但有一次
test.test2[0] = 0;
达到,我得到以下异常:
First-chance exception at 0x00401028 in test.exe: 0xC0000005: Access violation writing location 0x1000c030.
我真的不知道出了什么问题。也许有人可以给我一个建议?
先感谢您。