Parsing C Header Files in C #

I am working with Visual Studio C #, and I need to parse the C header files to retrieve information only about function declarations contained inside. For each function I need a name, return type and its parameters. If possible, I need parameters in the order in which they appear in the function declaration. I saw material on the Internet about using visual studio tags or Exhuberant Ctags, etc. But from what I have compiled, these are not the options that allow me to parse from my C # program with C # code (maybe I'm wrong?). I also looked through all the other answers to related questions, but they don't seem to apply to my situation (I can just be dumb). If I could at least get all the lines of code representing function declarations,I would have a good start and I could manually make out the rest. thanks in advance

+2
source share
1 answer

To “parse” C (header) files in the deepest sense and get type information for function declarations, in practice you need to:

  • full preprocessor (including vendor-added pecaddillos, MS has some pretty weird stuff in its headers)
  • full (syntactic) AST parser / builder for the dialect C of interest (there is no such thing as "C", there is what the seller offers in this revision of the compiler)
  • building a table with a full character (since typedef are aliases for actual types of interests)

" ( C)". ; , , . , C, .

C ;

 T*X;

A .

C, . ( ), , typedefs, undefined , , C, .

, . Clang , , MS. GCC - , , C, MS C. DMS Software Reengineering Toolkit MS C.

, , , , - . , . # C , , C # , , API # C. "" #. , , , . GCC ; . Clang DMS , .

, , ; , , , , . , ( " ..." ). , , . , GCC Clang MS-; , DMS . . C/++ Visual Studio?

+2

Source: https://habr.com/ru/post/1793854/


All Articles