visual c++ - call to longjmp is causing programme to exit with code 0 on msvc 2010 -


i'm trying use setjmp/longjmp error handling, however, call longjmp causing programme exit code 0 when compiled using msvc 2010, here full message:

the program '[5020] test.exe: native' has exited code 0 (0x0). 

here code:

#include <setjmp.h> #include <stdio.h>  int main(void) {     jmp_buf env;     switch(setjmp(env))     {     case 0:         printf("normal operation\n");         longjmp(env, -2);         break;     case -1:         printf("known error\n");         break;     default:         printf("unknown error!\n");         break;     }     return 0; } 

i've compiled same code using gnu based compiler (bfin-elf-gcc under cygwin) worked fine. i.e.,

$ make bfin-elf-gcc -c -wall main.c -mcpu=bf533-any -o main.o bfin-elf-gcc main.o -mcpu=bf533-any -msim -o bfin_test  $ bfin-elf-run.exe bfin_test normal operation unknown error! 

any idea why not working on msvc?

many in advance, hasan.

longjmp(env, -2); triggers default: case prints unknown error! , emerges switch statement, return 0; performed. it's working wrote it. returning 0 main() same exiting 0. msvc telling exit value.


Comments