Pelles C forum
C language => Expert questions => Topic started by: akko on January 14, 2011, 02:46:17 PM
-
How can I generate software exceptions in Pelles C?
__try { some guarded code }
__except(EXCEPTION_EXECUTE_HANDLER) { some handler code }
void myThrow(int tc) // called from try block
{ RaiseException((DWORD)tc,0,0,NULL); // ??? does not work
}
-
#include <windows.h>
#include <stdio.h>
DWORD exception_filter(int* k)
{
return EXCEPTION_EXECUTE_HANDLER;
}
void myThrow(int tc) // called from try block
{
RaiseException((DWORD)tc,0,0,NULL); // does not work
}
int main(void)
{
int foo = 0;
__try
{
//*(DWORD *) 0 = 0xdeadbeef;
myThrow(0);
}
__except(exception_filter(&foo))
{
printf("Exception!\n");
}
return 0;
}
-
Thanks Timovjl, it works! :)