<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<font face="Verdana">What I am trying to do is print only those macros which are defined in the current file.</font><div><font face="Verdana">So whenever the PPCallback function MacroDefined is called, I test if the presumed file name is same as</font></div><div><font face="Verdana">the file currently being processed. If it is then print macro identifier etc...</font></div><div><font face="Verdana"><br></font></div><div><font face="Verdana">Relevant code is as follows...</font></div><div><font face="Verdana"><br></font></div><div><div><font face="Verdana">    void MacroDefined(const Token &MacroNameTok, const MacroInfo* MI)</font></div><div><font face="Verdana">    {</font></div><div><font face="Verdana">      if(MacroIsLocal(MI->getDefinitionLoc())) { </font></div><div><font face="Verdana">      //  if(MacroNameTok.getName()){ </font></div><div><font face="Verdana">        std::cout<<"Macro "<<MacroNameTok.getIdentifierInfo()->getNameStart()<<" is defined here\n\t"; </font></div><div><font face="Verdana">        //std::cout<<"Macro "<<tok::getTokenName(MacroNameTok.getKind())<<" is defined here\n\t"; </font></div><div><font face="Verdana">        if(MI->isFunctionLike()) </font></div><div><font face="Verdana">          std::cout<<"The macro is function like\n"; </font></div><div><font face="Verdana">        if(MI->isObjectLike()) </font></div><div><font face="Verdana">          std::cout<<"The macro is object like\n"; </font></div><div><font face="Verdana">      } </font></div><div><font face="Verdana">    } </font></div><div><span style="font-size: 10pt; "><font face="Verdana">    </font></span></div><div><font face="Verdana">    ///if the macro is local to the current file being processed </font></div><div><font face="Verdana">    bool MacroIsLocal(SourceLocation loc) </font></div><div><font face="Verdana">    { </font></div><div><font face="Verdana">      /// the source manager can decode the SourceLocation information </font></div><div><font face="Verdana">      PresumedLoc presumed = sm->getPresumedLoc(loc);//sm is the SourceManager for the current file </font></div><div><font face="Verdana">      if(file_name == presumed.getFilename()) </font></div><div><font face="Verdana">        return true; </font></div><div><font face="Verdana">      return false; </font></div><div><font face="Verdana">    } </font></div></div><div><font face="Verdana"><br></font></div><div><font face="Verdana">When I do not call <span style="font-size: 10pt; ">    `bool MacroIsLocal(SourceLocation loc)' </span></font></div><div><span style="font-size: 10pt; "><font face="Verdana">It prints all the macros(including the predefined macros) without any errors. </font></span></div><div><span style="font-size: 10pt; "><font face="Verdana">What could be the problem... or is there any other way to </font></span></div><div><span style="font-size: 10pt; "><font face="Verdana">find out which macros are local to the file being processed. </font></span></div><div><span style="font-family: Verdana; font-size: 10pt; "> </span></div><div><span style="font-family: Verdana; font-size: 10pt; "><br></span></div><div><font face="Verdana">Thanks for the help.</font></div><div><font face="Verdana">Aditya</font></div>                                           </div></body>
</html>