problem with setjmp
From: candy (candy_init_at_yahoo.com)
Date: 11/28/04
- Next message: Jason Taylor: "Re: C/C++ code beautifier"
- Previous message: Joe Wright: "Re: Systems software versus applications software definitions"
- Next in thread: Merrill & Michele: "Re: problem with setjmp"
- Reply: Merrill & Michele: "Re: problem with setjmp"
- Reply: Jack Klein: "Re: problem with setjmp"
- Reply: Chris Torek: "Re: problem with setjmp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Nov 2004 08:37:01 -0800
hi all,
Consider the following C code:
void funct(){
}
int main(){
int x;
x=funct;
printf("%x\n",x);
return 0;
}
It prints the address of the function funct().It means that
the function funct() is in the process stack even before it is
called.So,it should be safe to call setjmp in the function
funct() in the following way:
jmp_buf env;
int funct(){
if(setjmp(env)==1)
printf("called by longjmp\n");
return 0;
}
int main(void){
funct();
longjmp(env,1);
return 0;
}
On execution,the above program crashes.Can anybody please tell me
that what is the problem.
Thanks.
- Next message: Jason Taylor: "Re: C/C++ code beautifier"
- Previous message: Joe Wright: "Re: Systems software versus applications software definitions"
- Next in thread: Merrill & Michele: "Re: problem with setjmp"
- Reply: Merrill & Michele: "Re: problem with setjmp"
- Reply: Jack Klein: "Re: problem with setjmp"
- Reply: Chris Torek: "Re: problem with setjmp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|