在哪里可以找到它的。h函数实现?

时间:2022-07-17 06:26:33

I study C and I noticed that I can't find the implementation file for some header files like, for example, stdio.h which is a library which contains a lot of input/output functions, like printf. Where can I find its implementation?

我研究了C,发现我找不到一些头文件的实现文件,例如stdio。它是一个包含大量输入/输出函数的库,如printf。在哪里可以找到它的实现?

5 个解决方案

#1


25  

Download one of these:

下载其中一个:

Or, even better, download several of these and compare their implementations. Of course, these are likely doing a lot of things different compared to your particular standard library implementation, but would still be quite interesting for e.g. non-platform-specific functionality such as sprintf.

或者,更好的是,下载其中的几个并比较它们的实现。当然,与特定的标准库实现相比,这些工具可能会做很多不同的事情,但是对于非特定于平台的功能(如sprintf)来说,它们仍然是非常有趣的。

#2


6  

For example here. Google is your friend - just search for stdio.c. But note that you should handle these as "one implementation of many possible" - you don't know how your compiler is doing it by reading those, you just get an idea of how it can be done.

例如在这里。谷歌是你的朋友-只要搜索stdi .c。但是请注意,您应该将它们作为“多种可能的一种实现”来处理——您不知道编译器是如何通过读取这些实现的,您只需要了解如何实现它们。

#3


6  

You need to find the source code for a C standard library like glibc: http://www.gnu.org/s/libc/

您需要找到C标准库的源代码,如glibc: http://www.gnu.org/s/libc/

You can download the source here: http://ftp.gnu.org/gnu/glibc/ It contains source for all the library functions.

您可以在这里下载源代码:http://ftp.gnu.org/gnu/glibc/它包含所有库函数的源代码。

#4


2  

If you install the Windows SDK, there is an option to include the standard library source code, so you can also see how it is implemented on Windows.

如果您安装了Windows SDK,那么有一个选项可以包含标准库源代码,因此您也可以看到如何在Windows上实现它。

#5


1  

On Ubuntu or other OS that uses aptitude for package management, you can use:

在Ubuntu或其他操作系统上,你可以使用:

apt-get source libc6

for example.

为例。

Also, running gcc in verbose mode will tell you the details of the paths it is using. This should help you find which include and library paths it's using.

此外,以详细模式运行gcc将告诉您它使用的路径的详细信息。这将帮助您找到它使用的包含路径和库路径。

gcc -v

or

gcc -Wl,--verbose

#1


25  

Download one of these:

下载其中一个:

Or, even better, download several of these and compare their implementations. Of course, these are likely doing a lot of things different compared to your particular standard library implementation, but would still be quite interesting for e.g. non-platform-specific functionality such as sprintf.

或者,更好的是,下载其中的几个并比较它们的实现。当然,与特定的标准库实现相比,这些工具可能会做很多不同的事情,但是对于非特定于平台的功能(如sprintf)来说,它们仍然是非常有趣的。

#2


6  

For example here. Google is your friend - just search for stdio.c. But note that you should handle these as "one implementation of many possible" - you don't know how your compiler is doing it by reading those, you just get an idea of how it can be done.

例如在这里。谷歌是你的朋友-只要搜索stdi .c。但是请注意,您应该将它们作为“多种可能的一种实现”来处理——您不知道编译器是如何通过读取这些实现的,您只需要了解如何实现它们。

#3


6  

You need to find the source code for a C standard library like glibc: http://www.gnu.org/s/libc/

您需要找到C标准库的源代码,如glibc: http://www.gnu.org/s/libc/

You can download the source here: http://ftp.gnu.org/gnu/glibc/ It contains source for all the library functions.

您可以在这里下载源代码:http://ftp.gnu.org/gnu/glibc/它包含所有库函数的源代码。

#4


2  

If you install the Windows SDK, there is an option to include the standard library source code, so you can also see how it is implemented on Windows.

如果您安装了Windows SDK,那么有一个选项可以包含标准库源代码,因此您也可以看到如何在Windows上实现它。

#5


1  

On Ubuntu or other OS that uses aptitude for package management, you can use:

在Ubuntu或其他操作系统上,你可以使用:

apt-get source libc6

for example.

为例。

Also, running gcc in verbose mode will tell you the details of the paths it is using. This should help you find which include and library paths it's using.

此外,以详细模式运行gcc将告诉您它使用的路径的详细信息。这将帮助您找到它使用的包含路径和库路径。

gcc -v

or

gcc -Wl,--verbose