[cfe-dev] Leave conditional directives untouched by Preprocessor
João Matos
ripzonetriton at gmail.com
Tue Jul 17 05:54:55 PDT 2012
Take a look at Lex/PPCallbacks.h.
On Mon, Jul 16, 2012 at 11:33 PM, Ivan <ivanhoe12 at gmail.com> wrote:
> Hello everyone!
>
> I'm experimenting on Clang trying to build some specific C preprocessor.
> One thing I don't want him to do is to process conditional directives.
> For example if there is such an expression in the code:
>
> #if SOME_CONDITION
> int i = 1;
> #else
> int i = 2;
> #endif
>
> a normal preprocessor will process it to "int i = 1;" or "int i = 2;"
> depending
> on condition. But I want my preprocessor to leave this expression untouched.
>
> I want to ask what is the best way to do this? Is there some option for
> Preprocessor or PreprocessorLexer or Lexer class? I've looked through their
> code but did't find nothing which can help in this case (I don't want to
> modify their code because I want my program to work with vanilla Clang).
>
> Now I'm going to make a derived class of Preprocessor (or Lexer) and
> override
> appropriate methods. But maybe there is more simple and elegant solution.
>
> Thanks,
> Ivan.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
--
João Matos
More information about the cfe-dev
mailing list