【发布时间】:2011-09-04 02:27:16
【问题描述】:
我是 C++ 新手,我正面临访问冲突异常。 问题如下,我有包含结构的 backend.h 文件
struct Config
{
....
}conf;
get_conf();
backend.cpp 中的实现
Config get_conf()
{
return conf;
}
backend.cpp 和 backend.h 被编译生成一个 dll。 这个 dll 以这种方式包含在 VS 解决方案中
Config config = get_config();
Config *g_config = &config;
代码编译运行良好,但调用函数时抛出异常
First-chance exception at 0x75d6d36f in BA.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x002ec494..
First-chance exception at 0x75d6d36f in BA.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x002ebe28..
First-chance exception at 0x75d6d36f in BA.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x77962d37 in BA.exe: 0xC0000005: Access violation reading location 0x41ce5ab2.
Unhandled exception at 0x77962d37 in BA.exe: 0xC0000005: Access violation reading location 0x41ce5ab2.
The program '[4624] BA.exe: Native' has exited with code -1073741819 (0xc0000005).
我认为问题与指针和结构有关,请帮助我
【问题讨论】:
标签: c++ visual-studio visual-studio-2010 pointers