我是 C 的新手,我遇到了这个声明:
"Functions need to be declared in .h files and not defined with exception of inline functions".
那么我的问题是,标准函数在哪里定义?
最佳答案
"Functions need to be declared in .h files and not defined with exception of inline functions".
您在 header 中声明了一个函数的存在。供所有家属查看。
您在源文件中实现(定义)函数。家属看不到这个。
头文件是 API 或您的 C 文件,用于在应用程序的其他地方使用,隐藏实现。
内联函数的异常(exception)与以下事实有关,即在编译依赖项时,编译器必须知道放置而不是函数调用的内容。
仅在源文件中(私有(private))使用的函数不需要在头文件中声明。为什么要告诉其他代码呢?
My question is then where are standard functions defined?
在编译库中。你只知道它们存在,而不知道它们存在的地方。实现对您隐藏。 linker连接点。
关于c - 我应该在 .h 文件中定义函数还是只声明它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62275590/