Jump to content
  • Advertisement
Sign in to follow this  
andrew111

Tool (c/c++) for parsing/evaluating a c header file?

This topic is 2381 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm looking for a tool/library to parse a c header file, while also evaluating the preprocessor macros and any calculations like the values of enum items or any constant math expressions.(things usually done during compile time e.g."#define bla ~4 << 2").

I've been using swig with the xml output, but I find it painful to generate all the xml files, and then parsing them and calculating all the math expressions, enums, and then storing values of identifiers to be used in further math expression. Also swig has trouble with some uses of unions in structs as well.

I've been searching, but I haven't really found anything to fit that criteria. though there seems to be a lot of libaries out there that do parsing, so I am hoping that I've missed or overlooked one that could help me.

Thanks.

Share this post


Link to post
Share on other sites
Advertisement

I haven't used it, so take this with a huge pinch of salt, but I believe this is one of the main use-cases for LLVM. See, for example, Writing an LLVM Pass.


Looks promising, thanks.

... taking forever to compile though :)

Share this post


Link to post
Share on other sites

I use mcpp a standard c/c++ preprocessor to build my shader/xml files.


Looks pretty useful, but not enough for what I need.

I've given up on anything c/c++ based, can't get any of the libraries/tools to compile under windows/mingw/cygwin.

Python seems to have a few c parsing tools like pycparser, and it takes hardly any effort to install unlike c/c++.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!