简体   繁体   English

从现有的开源 C 库中提取 function 源代码

[英]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).我需要从现有的 C 库(该库是开源的)中提取 function 的源代码。 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.问题是函数是使用 header 文件中的宏创建的,当我编写测试项目并将库链接到它时,调试器将我指向 header 文件的“转到定义”操作。 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).我需要从现有的 C 库(该库是开源的)中提取 function 的源代码。

Several C compilers are themselves open source.几个 C 编译器本身是开源的。 Both GCC and Clang are (and so is tinycc ). GCCClang都是( 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 .此外,最近的 GCC 版本(例如 2020 年 7 月, GCC 10 )接受插件 Your GCC plugin could work on some internal GCC representations (eg GIMPLE , GENERIC ) so will know about functions (even obtained by preprocessor expansion).您的 GCC 插件可以在某些内部 GCC 表示(例如GIMPLEGENERIC )上工作,因此将了解函数(甚至通过预处理器扩展获得)。

You could also consider using some open source static program analyzers, such as Frama-C or Clang static analyzer .您还可以考虑使用一些开源 static 程序分析器,例如Frama-CClang static 分析器

PS. 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).我不是律师(如果你混合使用不同开源许可证的各种软件,你可能需要问一个)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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