关于清理栈的迷惑
刚刚开始学习symbian 遇到了一个让我很费解的问题 请大虾帮忙啊
我弄了一个控制台的程序 程序如下:
#include <e32base.h>
#include <e32std.h>
#include <e32cons.h> // Console
//#include <euser.h>
// Global Variables
GLDEF_D CConsoleBase* console; // write all messages to this
void DoTheThingsForMeL(CConsoleBase* aConsole)
{
aConsole->Write(_L("hello world!"));
// aConsole->Getch();
}
void DoExampleL()
{
// Make the console and push it on the cleanup stack.
CleanupStack::PushL(console);
DoTheThingsForMeL(console);
CleanupStack::PopAndDestroy(console);
}
TInt E32Main()
{
__UHEAP_MARK;
//Create a cleanup stack
CTrapCleanup* cleanup = CTrapCleanup::New();
console = Console::NewL(_L("Console"), TSize( KConsFullScreen, KConsFullScreen));
//Call some Leaving methods inside TRAP
TRAPD(error, DoExampleL());
//Destroy cleanup stack
delete cleanup;
__UHEAP_MARKEND;
return 0;
}
我有一个问题就是为什么 DoExampleL()这个函数必须要写在宏TAAPD里面?单独拿出来就出错,有的人说是因为函数中有CleanupStack::Push()这样的对于清理栈的操作,但是我的理解console = Console::NewL(_L("Console"), TSize( KConsFullScreen, KConsFullScreen)); 这句中应该也包含着这样的操作为什么这样可以?
请高人指点~~