简体   繁体   English

stdlib.h,stdio.h中所有函数和常量的引用?

[英]Reference of all functions and constants in stdlib.h, stdio.h?

I'd like to look up all the functions, constants and types defined in C libraries: stdlib.h , stdio.h , ctype.h etc. So, when in C program I do: #include <stdlib.h> or #include <stdio.h> I'd like to know what are all the functions, constants and types I get with that? 我想查找C库中定义的所有函数,常量和类型: stdlib.hstdio.hctype.h等。因此,在C程序中时,我会执行: #include <stdlib.h>#include <stdio.h>我想知道我从中得到的所有函数,常量和类型是什么?

What's the easiest way to do this locally on the computer ? 在计算机上本地执行此操作的最简单方法是什么? I'm not so much interested in online references, especially if they're not official. 我对在线参考文献不太感兴趣,特别是如果它们不是官方的。

Is there a manpage that lists this for eg stdlib ? 是否有手册页列出了例如stdlib Does maybe GNU info program have docs for this? 也许GNU info程序对此具有文档? Or do I have to find an actual header file and look it up? 还是我必须找到一个实际的头文件并进行查找?

I'd prefer an universal approach, but if it differs from system to system I'm curious how to do that on both Mac and Linux? 我更喜欢通用的方法,但是如果系统之间存在差异,我很好奇如何在Mac和Linux上做到这一点?

Your terminology stdlib is not well-defined. 您的术语stdlib定义不明确。 There's a "Standard I/O Library" as part of the C Programming Language, and a stdlib.h header file. C编程语言中有一个“标准I / O库”,以及一个stdlib.h头文件。

For C identifiers, here's an overview for ISO C and POSIX identifiers . 对于C标识符,这是ISO C和POSIX标识符的概述。

Apart from that, you can look at the symbols in library files with 除此之外,您还可以使用以下命令查看库文件中的符号

nm -AP /path/to/libfoobar.a

Update 更新资料

To inspect a header in the form the compiler sees it, look at the result of preprocessing ( -E ): 要检查编译器看到的标题形式,请查看预处理结果( -E ):

$ gcc -E /usr/include/stdlib.h|less
typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;
[...]
typedef struct
  {
    int quot;
    int rem;
  } div_t;
typedef struct
  {
    long int quot;
    long int rem;
  } ldiv_t;
[...]
extern long int random (void) __attribute__ ((__nothrow__ , __leaf__));
[...]

When you include one of the standard C headers, at least three types of identifiers may be declared: 当包含标准C标头之一时,至少可以声明三种类型的标识符:

  • Identifiers specified by the C standard. C标准指定的标识符。 The authoritative source for information on these is the C standard , plus documentation for the C implementation you are using. 有关这些信息的权威来源是C标准以及您正在使用的C实现的文档。

  • Identifiers for extensions to the C language. C语言扩展的标识符。 For example, the headers may declare identifiers for POSIX functions. 例如,标头可以声明POSIX函数的标识符。 The headers might declare such identifiers only if you have requested them by defining certain preprocessor symbols before including the headers. 标头只有在您通过在包含标头之前定义某些预处理器符号来请求它们时,才声明此类标识符。

  • Identifiers for internal use of the C implementation. C实现内部使用的标识符。 These identifiers commonly begin with an underscore followed by another underscore or a caputal letter, as the C standard reserves those. 这些标识符通常以下划线开头,后跟另一个下划线或大写字母,因为C标准保留了这些标识符。 You can discover these identifiers by examining the actual header files in your C implementation, but you should not use them unless documentation for your implementation offers them for use. 您可以通过检查C实现中的实际头文件来发现这些标识符,但是除非您的实现文档允许使用它们,否则您不应使用它们。

Overall, if you want to know what C provides in the standard headers, you should read either the C standard (for authoritative information) or a good C textbook (for tutorial information). 总体而言,如果您想了解C在标准标头中提供的内容,则应阅读C标准(有关权威信息)或一本不错的C教科书(有关教程信息)。 If you want to know what else is in the headers, there is a large variety of things that an implementation could put into the headers, so the way to find out what is there is to read the documentation for the implementation and/or to examine the header file and then find the documentation for the extra things it provides, such as the POSIX documentation . 如果您想了解标头中还有什么,则实现可以将各种内容放入标头中,因此找出其中的方法是阅读实现的文档和/或检查头文件,然后找到其提供的其他内容的文档 ,例如POSIX文档

You asked for sources on your computer. 您在计算机上询问来源。 Your C implementation may come with documentation, and Unix includes documentation accessible via the man command. 您的C实现可能随附文档,Unix包含可通过man命令访问的文档。 While you can examine the actual header files, it is important to understand the current contents of the headers do not constitute any promise about future behavior. 虽然您可以检查实际的头文件,但重要的是要了解头文件的当前内容不构成有关将来行为的任何保证。 Any internal identifiers may change in future versions, and the behavior of standard identifiers may change as permitted by the C standard. 在将来的版本中,任何内部标识符都可能会更改,并且标准标识符的行为可能会根据C标准的允许而更改。

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

相关问题 header 文件之间的区别“<stdio.h> “ 和 ”<stdlib.h> ”</stdlib.h></stdio.h> - difference between header files “<stdio.h>” and “<stdlib.h>” 使用stdlib.h或stdio.h中的某些函数会导致语法错误 - Using certain functions from stdlib.h or stdio.h causes syntax errors 是否可以使用stdio.h和stdlib.h从特定路径打开目录? - Is there a way of opening a directory from a specific path using stdio.h and stdlib.h? 为什么stdio.h、stdlib.h、string.h声明size_t、NULL等而不是#include<stddef.h> ?</stddef.h> - Why stdio.h, stdlib.h, string.h declare size_t, NULL, etc. instead of #include <stddef.h>? 直接在汇编中使用 stdlib.h 函数 - Using stdlib.h functions directly in assembly 如何让 C 程序向文件内容添加行号。 例如,“1. #include<stdio.h> 2.#include<stdlib.h> “, ETC。?</stdlib.h></stdio.h> - How can you make a C program add line numbers to a file's contents. E.g., "1. #include <stdio.h> 2. #include <stdlib.h>", etc.? string.h和stdlib.h函数给我错误:未定义引用“…” - string.h and stdlib.h functions give me the error: undefined reference to '…' stdio.h 包含函数的定义或声明? - stdio.h contains definition or declaration of functions? 在哪里找到stdio.h函数实现? - Where to find stdio.h functions implementations? 关于stdio.h - Regarding stdio.h
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM