Extracting preprocessor symbols from source

后端 未结 2 1347
北海茫月
北海茫月 2021-02-13 07:06

I\'m looking for a way to extract all preprocessor symbols used in my code.
As an example, if my code looks like this:

#ifdef FOO
#endif

#if ( BAR == 1 &         


        
2条回答
  •  面向向阳花
    2021-02-13 07:16

    You can get half way there by using a preprocessor library such as Boost.Wave. It can act as a lexer so you wouldn't have to write that part yourself. You would have to supply a grammar for the bit you cared about (define, ifdef, ifndef, if, elif) though.

提交回复
热议问题