是否可以修改C++中的調用棧? (我知道這是一個可怕的想法和我真的只是想知道----我不打算實際上這樣做)修改調用棧
例如:
void foo(){
other();
cout << "You never see this" << endl; //The other() function modifies the stack to
//point to what ever called this function...so this is not displayed
}
void other(){
//modify the stack pointer here somehow to go down 2 levels
}
//Elsewhere
foo();
是的,你可以。但是你需要知道堆棧幀是什麼樣的。這是編譯器和平臺的依賴。你使用的是什麼操作系統和編譯器? –
1.拋出一個異常,2'setjmp' /'longjmp' –
@RichardHodges我真的只要求好奇的緣故(所以我實際上沒有一個需要解決的問題) – DarthRubik