Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C code preprocessing in Perl

I work on the C code parser in Perl.

At the moment I need to pre-process the code. Implementation of the pre-processing seems to be a lot of work, so I am looking for a script or library that will allow to pre-process the file.

I found the following possibilities:

  1. Text::CPP
  2. Filter::CPP

Both of these require cpp which I don't have on my Windows machine. Are there any other options?

like image 660
Alex Avatar asked Jun 18 '13 11:06

Alex


1 Answers

I'm not sure I understand your needs, but you are right that implementing this yourself is probably a poor choice. I was recently looking for alternative C preprocessors as well.

The Text::CPP module should only require a compiler to compile itself. If you can find a precompiled version, it should work for you.

The JCPP Java C Preprocessor by the same author could probably be made to work. You'd likely have to process externally and then load the result.

Filepp is an older Perl program that claims CPP compatability. There is a precompiled Windows binary to download.

There is a brand new Lua C-Preprocessor LCPP that might be something you could work with. Probably best as a standalone, but you might be able to use Inline::Lua.

SWIG comes with its own preprocessor implementation. I presume this would be available for Windows.

What else? The Boost Wave Preprocessor might work well and is available for Windows. The MSVC Compiler can preprocess to a file.

Still, the easiest and best long term solution may be to just install CPP. It comes as part of GCC, which you can get from Cygwin or MinGW.

like image 138
Nathan Kurz Avatar answered Sep 25 '22 02:09

Nathan Kurz