mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-06 10:57:50 +08:00
解决在window mingw 5.3环境下编译出现报错信息 (#4710)
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
Linux_Python / build (push) Has been cancelled
macOS / build (push) Has been cancelled
macOS_Python / build (push) Has been cancelled
Windows / build (push) Has been cancelled
Windows_Python / build (push) Has been cancelled
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
Linux_Python / build (push) Has been cancelled
macOS / build (push) Has been cancelled
macOS_Python / build (push) Has been cancelled
Windows / build (push) Has been cancelled
Windows_Python / build (push) Has been cancelled
解决在window mingw 5.3环境下编译出现如下报错信息
no known conversion from 'LONG (*)(EXCEPTION_POINTERS*) {aka long int
(*)(_EXCEPTION_POINTERS*)}' to 'LPTOP_LEVEL_EXCEPTION_FILTER {aka long
int (__attribute__((__stdcall__)) *)(_EXCEPTION_POINTERS*)}'
This commit is contained in:
parent
c3c0fb4448
commit
502ee6a497
@ -185,6 +185,32 @@ void System::startDaemon(bool &kill_parent_if_failed) {
|
|||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
static LONG __stdcall customUnhandledExceptionFilter(EXCEPTION_POINTERS *pException) {
|
||||||
|
// 生成 dump 文件名,带时间戳
|
||||||
|
char dumpPath[MAX_PATH];
|
||||||
|
std::time_t t = std::time(nullptr);
|
||||||
|
std::tm tm;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
localtime_s(&tm, &t);
|
||||||
|
#else
|
||||||
|
tm = *std::localtime(&t);
|
||||||
|
#endif
|
||||||
|
std::strftime(dumpPath, sizeof(dumpPath), "crash_%Y%m%d_%H%M%S.dmp", &tm);
|
||||||
|
|
||||||
|
HANDLE hFile = CreateFileA(dumpPath, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||||
|
if (hFile != INVALID_HANDLE_VALUE) {
|
||||||
|
MINIDUMP_EXCEPTION_INFORMATION mdei;
|
||||||
|
mdei.ThreadId = GetCurrentThreadId();
|
||||||
|
mdei.ExceptionPointers = pException;
|
||||||
|
mdei.ClientPointers = FALSE;
|
||||||
|
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &mdei, nullptr, nullptr);
|
||||||
|
CloseHandle(hFile);
|
||||||
|
}
|
||||||
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
|
}
|
||||||
|
#endif//!defined(_WIN32)
|
||||||
|
|
||||||
void System::systemSetup(){
|
void System::systemSetup(){
|
||||||
|
|
||||||
#ifdef ENABLE_JEMALLOC_DUMP
|
#ifdef ENABLE_JEMALLOC_DUMP
|
||||||
@ -238,29 +264,7 @@ void System::systemSetup(){
|
|||||||
std::ios_base::sync_with_stdio(false);
|
std::ios_base::sync_with_stdio(false);
|
||||||
|
|
||||||
// 注册crash自动生成dump(等价core dump)
|
// 注册crash自动生成dump(等价core dump)
|
||||||
SetUnhandledExceptionFilter([](EXCEPTION_POINTERS *pException) -> LONG {
|
SetUnhandledExceptionFilter(customUnhandledExceptionFilter);
|
||||||
// 生成 dump 文件名,带时间戳
|
|
||||||
char dumpPath[MAX_PATH];
|
|
||||||
std::time_t t = std::time(nullptr);
|
|
||||||
std::tm tm;
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
localtime_s(&tm, &t);
|
|
||||||
#else
|
|
||||||
tm = *std::localtime(&t);
|
|
||||||
#endif
|
|
||||||
std::strftime(dumpPath, sizeof(dumpPath), "crash_%Y%m%d_%H%M%S.dmp", &tm);
|
|
||||||
|
|
||||||
HANDLE hFile = CreateFileA(dumpPath, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
|
||||||
if (hFile != INVALID_HANDLE_VALUE) {
|
|
||||||
MINIDUMP_EXCEPTION_INFORMATION mdei;
|
|
||||||
mdei.ThreadId = GetCurrentThreadId();
|
|
||||||
mdei.ExceptionPointers = pException;
|
|
||||||
mdei.ClientPointers = FALSE;
|
|
||||||
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &mdei, nullptr, nullptr);
|
|
||||||
CloseHandle(hFile);
|
|
||||||
}
|
|
||||||
return EXCEPTION_EXECUTE_HANDLER;
|
|
||||||
});
|
|
||||||
#endif//!defined(_WIN32)
|
#endif//!defined(_WIN32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user