C的头文件中的函数体在哪里
当我查看 C(或 C++)的头文件时 例如 stdio.h 有一些函数的定义 例如
_CRTIMP FILE* __cdecl __MINGW_NOTHROW fopen (const char*, const char*);
_CRTIMP FILE* __cdecl __MINGW_NOTHROW freopen (const char*, const char*, FILE*);
_CRTIMP int __cdecl __MINGW_NOTHROW fflush (FILE*);
_CRTIMP int __cdecl __MINGW_NOTHROW fclose (FILE*);
/* MS puts remove & rename (but not wide versions) in io.h also */
_CRTIMP int __cdecl __MINGW_NOTHROW remove (const char*);
_CRTIMP int __cdecl __MINGW_NOTHROW rename (const char*, const char*);
_CRTIMP FILE* __cdecl __MINGW_NOTHROW tmpfile (void);
_CRTIMP char* __cdecl __MINGW_NOTHROW tmpnam (char*);
你能告诉我吗 这些函数的主体在哪里......
When i look at header files files of C(or C++)
for example
stdio.h
there are definition of some functions
for example
_CRTIMP FILE* __cdecl __MINGW_NOTHROW fopen (const char*, const char*);
_CRTIMP FILE* __cdecl __MINGW_NOTHROW freopen (const char*, const char*, FILE*);
_CRTIMP int __cdecl __MINGW_NOTHROW fflush (FILE*);
_CRTIMP int __cdecl __MINGW_NOTHROW fclose (FILE*);
/* MS puts remove & rename (but not wide versions) in io.h also */
_CRTIMP int __cdecl __MINGW_NOTHROW remove (const char*);
_CRTIMP int __cdecl __MINGW_NOTHROW rename (const char*, const char*);
_CRTIMP FILE* __cdecl __MINGW_NOTHROW tmpfile (void);
_CRTIMP char* __cdecl __MINGW_NOTHROW tmpnam (char*);
Can you tell me
where are the body of theese functions.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,正如@Daren Thomas所说,您将拥有与hader(.h文件)匹配的.c文件。然而,对于标准库,这些c文件是预先编译好的并放在一个大文件中(例如libc.so),并且可以在Windows中编译器的lib文件夹中以及/usr/lib文件夹中找到在 Unix/Linus 操作系统中。
对于g++,libc库被用作标准库。您可以从这里下载该软件包:
http://ftp.gnu.org /gnu/glibc/glibc-2.9.tar.gz
...并浏览所有函数的源代码。
Normally, as @Daren Thomas said, you'll have .c file matching the hader (.h file). However, regarding the standard library, these c files come precompiled and put together in a big file (for example, libc.so), and can be found in the lib folder of your compiler in Windows, and in the /usr/lib folder in Unix/Linus OS's.
For g++, the libc library is used as the standard library. You can download the package from here:
http://ftp.gnu.org/gnu/glibc/glibc-2.9.tar.gz
... and browse the source code for all functions.
通常,正文位于同名的文件中,但以
.c
或.cpp
结尾。有时您没有源代码,因此请查找
.o
,其中包含您的库的目标代码,即编译后的库。头文件就是一种 API 描述。在特殊情况下,例如作为标准库一部分的stdio.h,这些文件的位置是特定于实现的。事实上,这些文件的存在也是特定于实现的 - 我相信编译器可以选择提供此信息,但它愿意这样做。
Normally, the body is in a file with the same name, but ending in
.c
or.cpp
.Sometimes you don't have the source code, so look for
.o
, which contains the object code for your library, i.e. the compiled library. The header file is then a kind of API description.In special cases like
stdio.h
, which are part of the standard library, the location of these files are implementation specific. In fact, the existence of these files are implementation specific too - I believe a compiler may choose to provide this information however it pleases to do so.