Define macro in program manually

Hi all,

I want to define macro by hand before running compile.

In code, I already setup a clang::Preprocessor.
I use:

mPP->setMacroInfo(&mPP->getIdentifierTable().get("__cplusplus"),
new clang::MacroInfo( mSourceMgr->getLocForStartOfFile( mSourceMgr->getMainFileID() ) ) );

But it segmentation fault and this is backtrace:

#0 llvm::StringMapImpl::LookupBucketFor (this=0xac, Name=…) at external/llvm/lib/Support/StringMap.cpp:56
#1 0x0805d180 in GetOrCreateValueclang::IdentifierInfo* (this=0xffea172c) at external/llvm/include/llvm/ADT/StringMap.h:370
#2 llvm::StringMap<clang::IdentifierInfo*, llvm::BumpPtrAllocator>::GetOrCreateValue (this=0xffea172c) at external/llvm/include/llvm/ADT/StringMap.h:392
#3 clang::IdentifierTable::get (this=0xffea172c) at external/clang/include/clang/Basic/IdentifierTable.h:362
#4 pndk::Compiler::setMacro (this=0xffea172c) at Compiler.cpp:269
#5 0x0805b259 in main (argc=8, argv=0xffea1a84) at Driver.cpp:71

I have no experience and no idea on clang macro handling.
Could someone help?

Big thanks!