gpt4 book ai didi

c++ - visual studio 中的 Onexit.c 错误?

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:30:56 25 4
gpt4 key购买 nike

当我尝试在 Release模式下运行我的程序时,它会直接运行到

Unhandled exception at 0x6f2426ef (msvcr100.dll) in FPS Game.exe: 0xC0000005: Access violation writing location 0x12817c19.

this is in the static _onexit_t __cdecl _dllonexit_nolock function in onxit.c on line 325 : *((*pend)++) = (_PVFV)func;

而且我不知道为什么我已经尝试了很多东西我也无法正常工作我已经将 sdl 链接到我的应用程序如果这就是原因但我真的需要帮助。

这是微软出错的代码:

static _onexit_t __cdecl _dllonexit_nolock (
_onexit_t func,
_PVFV ** pbegin,
_PVFV ** pend
)
{
_PVFV *p=NULL;
size_t oldsize;

/*
* First, make sure the table has room for a new entry
*/
if ( (oldsize = _msize_crt(*pbegin)) <= (size_t)((char *)(*pend) -
(char *)(*pbegin)) )
{
/*
* not enough room, try to grow the table
*/
size_t grow=__min(oldsize, MAXINCR * sizeof(_PVFV));
if((_HEAP_MAXREQ-grow<oldsize) ||
((p = (_PVFV *)_realloc_crt((*pbegin), oldsize + grow)) == NULL))
{
/*
* failed, try to grow by ONEXITTBLINCR
*/
grow=MININCR * sizeof(_PVFV);
if ( (_HEAP_MAXREQ-grow<oldsize) ||
((p = (_PVFV *)_realloc_crt((*pbegin), oldsize + grow)) == NULL ))
{
/*
* failed again. don't do anything rash, just fail
*/
return NULL;
}
}

/*
* update (*pend) and (*pbegin)
*/
(*pend) = p + ((*pend) - (*pbegin));
(*pbegin) = p;
}

/*
* Put the new entry into the table and update the end-of-table
* pointer.
*/
*((*pend)++) = (_PVFV)func;

return func;

}

最佳答案

根据多年的经验和许多类似的经验,我的经验法则之一是“不,你还没有发现编译器中的错误”。

首先使用调试信息构建版本 - 这至少应该让您看到堆栈并可能给您提示哪里出了问题。

通常这种问题是由

引起的
  • 使用错误的链接器设置或库(这是 MSVC 独有的/窗口)
  • 链接到一个不是用构建的发布库相同的代码生成选项;
  • 没有正确初始化变量(在 Debug模式下通常不会出现)
  • 在所有项目中没有一致的编译选项

关于c++ - visual studio 中的 Onexit.c 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12269072/

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