我有一个任务是为C程序开发源代码分析工具,需要在分析之前对代码进行预处理。我想知道哪个库最适合这个任务。我需要一个轻量级且便携的库。
不要自己开发,为什么不使用gcc套件中的cpp工具:http://gcc.gnu.org/onlinedocs/gcc-4.6.1/cpp/
CPP(1) GNU CPP(1)
NAME
cpp - The C Preprocessor
SYNOPSIS
cpp [-Dmacro[=defn]...] [-Umacro]
[-Idir...] [-iquotedir...]
[-Wwarn...]
[-M|-MM] [-MG] [-MF filename]
[-MP] [-MQ target...]
[-MT target...]
[-P] [-fno-working-directory]
[-x language] [-std=standard]
infile outfile
Only the most useful options are listed here; see below for the
remainder.
DESCRIPTION
The C preprocessor, often known as cpp, is a macro processor that is
used automatically by the C compiler to transform your program before
compilation. It is called a macro processor because it allows you to
define macros, which are brief abbreviations for longer constructs.
cpp
的方法来实现它。 - Kijancpp
更高效的方法来完成它。不过,由于其可移植性,我可能会使用cpp
。 - Kijan