gpt4 book ai didi

c++ - 删除 CStringArray* 时崩溃

转载 作者:太空宇宙 更新时间:2023-11-04 13:56:01 25 4
gpt4 key购买 nike

我是 C++ 世界的菜鸟,我面临着一种奇怪的行为。我使用 Visual Studio 2010。

上下文:我决定将 wxWidget 用于 GUI。

为此,我必须在我的项目属性中更改以下设置:

C/C++> 代码生成> 运行时库> /MTd(以前是/MDd)

一般> MFC的使用> 在共享DLL中使用MFC(之前是在静态库中使用MFC)

由于这些更改,我在 CStringArray* 上的所有 delete[] 都会使我的应用程序崩溃。我尝试通过 delete 更改 delete[] 但它会导致巨大的内存泄漏。

我不明白为什么项目设置中的这些更改会产生这种行为差异。

编辑:

输出信息为:

HEAP[xxx.exe]: Invalid address specified to RtlValidateHeap( 002B0000, 002BDE54 ) Windows has triggered a breakpoint in xxx.exe.

This may be due to a corruption of the heap, which indicates a bug in xxx.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while xxx.exe has focus.

我已阅读 that :

The CRT libraries use weak external linkage for the new, delete, and DllMain functions. The MFC libraries also contain new, delete, and DllMain functions. These functions require the MFC libraries to be linked before the CRT library is linked.

所以我尝试在 Properties> 添加 Configuration Properties> Linker> Input> Ignore特定默认库:nafxcwd.lib;libcmtd.lib;

没有变化。

在调用堆栈中,我看到调用的是 CStringArray::vector 删除析构函数。

最佳答案

所以,我放弃了。我在这个问题上留下了很多时间。我认为在我删除指针时会传播一个潜在的问题。

我要试试 Qt...

关于c++ - 删除 CStringArray* 时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21461744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com