Writing a standalone c preprocessor (like the old cpp) using the cpplib

Andre-Marcel Hellmund mail@andihellmund.com
Fri Oct 15 15:41:00 GMT 2010


Hey Oli,
> for a project I need a standalone c preprocessor and I was thinking about using
> the cpplib from the latest gcc-core 4.6 snapshot
> as the base library. Could maybe anyone please post a very brief guide on how to
> start and what files I have to look at. I am quite a beginner
> and kinda lost without some help. My idea is to write a frontend that reads in
> the files, include paths and the defines, then calls the libcpp to do
> the preprocessing and afterwards writes out the preprocessed files.
>    
Sorry for the question, but why do you want to (re)write the C 
preprocessor yourself? Although the preprocessor logic (libcpp.a) is 
integrated into the C compiler (cc1) in the meantime, there is still a 
stand-alone C preprocessr (cpp) which you could use for your purpose. Or 
is there any special requirement in your project to NOT use the shipped 
'cpp'?

Best regards,
Andi



More information about the Gcc-help mailing list