setjmp()返回值问题
#include<iostream.h>
#include<setjmp.h>
//using namespace std;
class rainbow
{
public:
rainbow()
{
cout<<"rainbow()"<<endl;
}
~rainbow()
{
cout<<"~rainbow()"<<endl;
}
};
jmp_buf kansas;
void OZ()
{
rainbow RB;
int i = 0;
for(i;i < 3;i++)
{
cout<<"there's no place like home"<<endl;
}
longjmp(kansas,47);
}
int main()
{
if(setjmp(kansas) == 0)
{
cout<<"tornado ,witch,munchkins...\n";
OZ();
}
else
{
cout<<"Auntie Em"<<"i had the strongest dream"<<endl;
}
system("PAUSE");
return 0;
}
问题1:我在DEV++中,用using namespace std;居然编译不通过,为何?
问题2:执行结果是:
tornado ,witch,munchkins...
rainbow()
there's no place like home
there's no place like home
there's no place like home
Auntie Em i had the strongest dream
在OZ()中调用longjmp后,应该是跳转到if(setjmp(kansas) == 0)这里了,这时候为何执行了else,难道setjmp(kansas)此时返回值不等于0?那应该等于多少?