Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
'id': slechte context voor intrinsieke functie
Opmerkingen
Intrinsieke kenmerken van gestructureerde uitzonderingsafhandeling zijn ongeldig in bepaalde contexten:
_exception_code()buiten een uitzonderingsfilter of__except-blok_exception_info()buiten een uitzonderingsfilter_abnormal_termination()buiten een__finallyblok
Als u de fout wilt oplossen, moet u ervoor zorgen dat de intrinsieken voor uitzonderingsafhandeling in de juiste context worden geplaatst.
Voorbeeld
In het volgende voorbeeld wordt C2707 gegenereerd.
// C2707.cpp
#include <windows.h>
#include <stdio.h>
LONG MyFilter(LONG excode)
{
return (excode == EXCEPTION_ACCESS_VIOLATION ?
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH); // OK
}
LONG func(void)
{
int x, y;
return(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? // C2707
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH);
__try
{
y = 0;
x = 4 / y;
return 0;
}
__except(MyFilter(GetExceptionCode()))
{
return(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? // ok
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH);
}
}
int main()
{
__try
{
func();
} __except(EXCEPTION_EXECUTE_HANDLER)
{
printf_s("Caught exception\n");
}
}