Question

I was wondering if there was a built in runtime parser for header files in C#. I have several different C header files that I want to parse (They will later be used to determine how a network packet will be deserialized).

Ideally, some option to load the .h file dynamically, create the struct, and then use reflection to somehow parse the struct, just not certain if there's a way to load the .h file at runtime to create the struct.

If there is no easy way to do this, I can just parse it manually.

Was it helpful?

Solution

No, there is no standard means by which to do this, and given that there isn't exact parity between C types (which vary with compilers and platforms) and CLR types, I don't know that a completely generic one could be written.

You're much better off parsing the data yourself.

OTHER TIPS

This comes pretty close: http://www.swig.org/

It is a wrapper generator that can read C++ files and generate wrappers in C# (or lots of other languages).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top