Best approach to parsing * .c / * files. H using C # for data type declarations and definitions
I need to parse .c / .h files for data declaration and extract type declarations. For example, I may need to extract a variable declaration and the corresponding data type, which might look like this:
typedef union
{
struct
{
unsigned char OG15 : 1,
...
OG0 : 1;
} Bits;
unsigned short Packed;
} OUTPUT_DESCRIPTOR;
OUTPUT_DESCRIPTOR DiscreteWord1;
So my questions would be (using C #):
- What would be the best way to store data type information?
- What's the best approach to parsing source files to extract declarations and data types?
thank
Mark
+1
source to share
1 answer
Not sure if this is the best approach, but I can suggest two working approaches:
- Use the Phoenix SDK to write a compiler pass that records this information.
- Compile the code with a regular C compiler, ask for a PDB file, then use the DIA API to read data structure definitions from PDB files.
+1
source to share