我不能在本机子系统中使用异常处理。
这是我的cpp文件:
#include <ntddk.h>
#include <exception>
int __cdecl main () {
try
{
throw 20;
}
catch (int e)
{
}
return 0;
}和我的资源文件:
TARGETNAME = native
TARGETTYPE = PROGRAM
UMTYPE = nt
USER_C_FLAGS=$(USER_C_FLAGS) /EHa
SOURCES = exeption.cpp \
INCLUDES=$(DDK_INC_PATH)
MINWIN_SDK_LIB_PATH=$(SDK_LIB_PATH)
TARGETLIBS=$(NTDLL_CRT) $(SDK_LIB_PATH)\ntdll.lib lib.lib我的错误是:
error LNK2019: unresolved external symbol ___CxxFrameHandler3 referenced in function __ehhandler$_main
error LNK2019: unresolved external symbol __EH_epilog3 referenced in function __catch$_main$0
error LNK2019: unresolved external symbol __EH_prolog3_catch referenced in function _main
error LNK2019: unresolved external symbol __CxxThrowException@8 referenced in function _main
error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)我该如何解决这个问题?
发布于 2012-05-09 22:40:10
这个问题在这里描述:http://www.codeproject.com/Articles/22801/Drivers-Exceptions-and-C和可能工作的解决方案,但可能会导致未定义的行为。
但是,您问题更简单:您需要编写包含一些DDK内容的用户模式程序。只需使用VC++构建环境(或Windows SDK),默认情况下包含所有CRT库,并包含用于DDK内容的ntddk.h文件。
如果你想在驱动程序中使用C++异常,答案很简单:永远不要这样做。
https://stackoverflow.com/questions/10517713
复制相似问题