开发者

C++ implementation of a C preprocessor

Does anyone know of a good C++ implementation of a standard C preprocessor?

I'm working on a C++ project which involves parsing C code, and I'd like to support mac开发者_开发知识库ros etc but am not interested in implementing a C preprocessor myself.

Ideally, the preprocessor would take in the filename of the main C file, and would return a stream of preprocessed C code.

Failing this, can anyone recommend a concise but comprehensive reference which covers C preprocessing?


GNU cpp, part of GCC, is very flexible and very good at parsing and preprocessing C code, although it's written in C instead of C++.


You may want to look at Boost.Wave.


You should look into using Lex and Yacc(also known as Flex and Bison, respectively). These are tools used for parsing languages. This excellent book is available in any respectable university library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜