简体   繁体   中英

Extract function source code from existing open source C library

I need to extract source code for a function from the existing C library (the library is open source). The problem is that functions are created using macros in header files, and when I write a test project and link the library to it the debugger points me to that header file on 'go to definition' action. I have the source code of the library and I guess i need to build it together with my test code (maybe this is not correct, I am not sure). Any advice on how to proceed, what to use? Thank you.

I need to extract source code for a function from the existing C library (the library is open source).

Several C compilers are themselves open source. Both GCC and Clang are (and so is tinycc ). So you legally could improve them (but that could take months of work).

In addition, recent GCC versions (eg in july 2020, GCC 10 ) accept plugins . Your GCC plugin could work on some internal GCC representations (eg GIMPLE , GENERIC ) so will know about functions (even obtained by preprocessor expansion).

You could also consider using some open source static program analyzers, such as Frama-C or Clang static analyzer .

PS. Take into account open source license issues (legal ones). I am not a lawyer (and you might need to ask one, if you mix various software of different open source licenses).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM