【问题标题】:List of standard header files in C and C++C 和 C++ 中的标准头文件列表
【发布时间】:2011-01-02 22:26:02
【问题描述】:

在哪里可以找到 C 和 C++ 中所有头文件的列表?

在构建库时,我收到类似“tree.h not found”的错误。 我想这是 C 和 C++ 中的标准头文件。这让我产生了想知道所有头文件及其贡献的好奇心。

有没有可以搜索的地方?

我正在开发 Solaris Unix。

【问题讨论】:

  • 您是在询问 C、C++ 还是两者?没有像 C/C++ 这样的语言,并且询问它是令人困惑的(请参阅下面的 C 标准头文件的详尽列表 - 这对您有用吗?)。
  • 我要求同时使用 C 和 C++
  • 您还关心系统上安装的标头

标签: c++ c header-files


【解决方案1】:

标题“tree.h”在任何地方都不是标准的。


C 标准

ISO/IEC 9899:1990(C89、C90)

C89 中的 15 个标准头文件是:

<assert.h>  <limits.h>  <signal.h>  <stdlib.h>
<ctype.h>   <locale.h>  <stdarg.h>  <string.h>
<errno.h>   <math.h>    <stddef.h>  <time.h>
<float.h>   <setjmp.h>  <stdio.h>

ISO/IEC 9899:1990/Amd.1:1995

C94*(修正案 1)中引入的 3 个额外标头是:

<iso646.h>  <wchar.h>  <wctype.h>

ISO/IEC 9899:1999 (C99)

C99 中额外的 6 个标头是:

<complex.h>  <inttypes.h>  <stdint.h>  <tgmath.h>
<fenv.h>     <stdbool.h>

ISO/IEC 9899:2011 (C11)

C2011 中的 5 个额外标题(总共 29 个)是:

<stdalign.h>  <stdatomic.h>  <stdnoreturn.h>  <threads.h>  <uchar.h>

ISO/IEC 9045:2008(POSIX 2008,单一 Unix 规范)

请注意,POSIX 需要更多的标头(82 个,包括所有 C99 标头)。下面的列表重复了标准 C (C99) 标头。当然,Windows 需要一组不同的标题。

<aio.h>        <libgen.h>       <spawn.h>         <sys/time.h>
<arpa/inet.h>  <limits.h>       <stdarg.h>        <sys/times.h>
<assert.h>     <locale.h>       <stdbool.h>       <sys/types.h>
<complex.h>    <math.h>         <stddef.h>        <sys/uio.h>
<cpio.h>       <monetary.h>     <stdint.h>        <sys/un.h>
<ctype.h>      <mqueue.h>       <stdio.h>         <sys/utsname.h>
<dirent.h>     <ndbm.h>         <stdlib.h>        <sys/wait.h>
<dlfcn.h>      <net/if.h>       <string.h>        <syslog.h>
<errno.h>      <netdb.h>        <strings.h>       <tar.h>
<fcntl.h>      <netinet/in.h>   <stropts.h>       <termios.h>
<fenv.h>       <netinet/tcp.h>  <sys/ipc.h>       <tgmath.h>
<float.h>      <nl_types.h>     <sys/mman.h>      <time.h>
<fmtmsg.h>     <poll.h>         <sys/msg.h>       <trace.h>
<fnmatch.h>    <pthread.h>      <sys/resource.h>  <ulimit.h>
<ftw.h>        <pwd.h>          <sys/select.h>    <unistd.h>
<glob.h>       <regex.h>        <sys/sem.h>       <utime.h>
<grp.h>        <sched.h>        <sys/shm.h>       <utmpx.h>
<iconv.h>      <search.h>       <sys/socket.h>    <wchar.h>
<inttypes.h>   <semaphore.h>    <sys/stat.h>      <wctype.h>
<iso646.h>     <setjmp.h>       <sys/statvfs.h>   <wordexp.h>
<langinfo.h>   <signal.h>

还要注意,X/Open Curses 需要另一组标头。 2009 年 11 月发布了该规范的新版本(第 7 版)(自 1996 年以来的第一次更新——主要区别在于失去了对 termcap 和准标准 C &lt;varargs.h&gt; 标头的官方支持)。

<curses.h>  <term.h>  <uncntrl.h>

Linux 标准库

您可能还需要使用其他标题。例如,在这些列表中没有提到 &lt;getopt.h&gt;,但如果您使用 GNU Getopt(例如,对于长选项),您将需要并使用该标头。根据LSB, Linux Standards Base,它是Linux 上的标准。旧版本的 LSB 在多个部分中被定义为 ISO/IEC 23360:2006;截至 2014 年 9 月 21 日,LSB 的当前版本为 4.1,但 5.0 版本处于测试阶段。文档的一部分定义了包含哪些标题,但在我查看的版本中没有方便的标题表。它与 POSIX 紧密结合,但具有超出 POSIX 定义的额外功能。


C++ 标准

ISO/IEC 14882:1998 (C++98)

标准列出了 32 个特定于 C++ 的标头:

<algorithm>   <iomanip>   <list>     <ostream>    <streambuf>
<bitset>      <ios>       <locale>   <queue>      <string>
<complex>     <iosfwd>    <map>      <set>        <typeinfo>
<deque>       <iostream>  <memory>   <sstream>    <utility>
<exception>   <istream>   <new>      <stack>      <valarray>
<fstream>     <iterator>  <numeric>  <stdexcept>  <vector>
<functional>  <limits>

还有18个头对应来自C的头(对应C94):

<cassert>  <ciso646>  <csetjmp>  <cstdio>   <ctime>
<cctype>   <climits>  <csignal>  <cstdlib>  <cwchar>
<cerrno>   <clocale>  <cstdarg>  <cstring>  <cwctype>
<cfloat>   <cmath>    <cstddef>

有趣的是,附件 D (§D.7) 列出了一个已弃用的标头 &lt;strstream&gt;,该标头在标准的前面没有提及。在 GCC (g++) 7.2.0 中包含该标头会生成警告:

/opt/gcc/v7.2.0/include/c++/7.2.0/backward/backward_warning.h:32:2:
warning: #warning This file includes at least one deprecated or antiquated
header which may be removed without further notice at a future date.
Please use a non-deprecated interface with equivalent functionality
instead. For a listing of replacement headers and interfaces, consult
the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]

标头&lt;strstream&gt; 明确列在标准的其他版本中。

ISO/IEC 14882:2011 (C++11)

C++11 中的 53 个 C++ 头文件是:

<algorithm>           <initializer_list>  <numeric>           <system_error>
<array>               <iomanip>           <ostream>           <thread>
<atomic>              <ios>               <queue>             <tuple>
<bitset>              <iosfwd>            <random>            <type_traits>
<chrono>              <iostream>          <ratio>             <typeindex>
<codecvt>             <istream>           <regex>             <typeinfo>
<complex>             <iterator>          <scoped_allocator>  <unordered_map>
<condition_variable>  <limits>            <set>               <unordered_set>
<deque>               <list>              <sstream>           <utility>
<exception>           <locale>            <stack>             <valarray>
<forward_list>        <map>               <stdexcept>         <vector>
<fstream>             <memory>            <streambuf>
<functional>          <mutex>             <string>
<future>              <new>               <strstream>

与C(C11)相关的26个头文件是:

<cassert>   <cinttypes>  <csignal>    <cstdio>   <cwchar>
<ccomplex>  <ciso646>    <cstdalign>  <cstdlib>  <cwctype>
<cctype>    <climits>    <cstdarg>    <cstring>
<cerrno>    <clocale>    <cstdbool>   <ctgmath>
<cfenv>     <cmath>      <cstddef>    <ctime>
<cfloat>    <csetjmp>    <cstdint>    <cuchar>

ISO/IEC 14882:2014 (C++14)

基于草案标准 N3797 的标头临时列表位于 ISO/IEC JTC1/SC22/WG21 站点。数据来自第 17.6.1.2 节 Headers 中的表 14 和 15,修改如下。由于该标准尚未发布(截至 2014-09-21),此列表尚未确定。

C++14 中的 54 个 C++ 头文件是:

<algorithm>           <initializer_list>  <numeric>           <strstream>
<array>               <iomanip>           <ostream>           <system_error>
<atomic>              <ios>               <queue>             <thread>
<bitset>              <iosfwd>            <random>            <tuple>
<chrono>              <iostream>          <ratio>             <type_traits>
<codecvt>             <istream>           <regex>             <typeindex>
<complex>             <iterator>          <scoped_allocator>  <typeinfo>
<condition_variable>  <limits>            <set>               <unordered_map>
<deque>               <list>              <shared_mutex>      <unordered_set>
<exception>           <locale>            <sstream>           <utility>
<forward_list>        <map>               <stack>             <valarray>
<fstream>             <memory>            <stdexcept>         <vector>
<functional>          <mutex>             <streambuf>
<future>              <new>               <string>

C(C11)相关的26个头文件与C++11相比没有变化:

<cassert>   <cinttypes>  <csignal>    <cstdio>   <cwchar>
<ccomplex>  <ciso646>    <cstdalign>  <cstdlib>  <cwctype>
<cctype>    <climits>    <cstdarg>    <cstring>
<cerrno>    <clocale>    <cstdbool>   <ctgmath>
<cfenv>     <cmath>      <cstddef>    <ctime>
<cfloat>    <csetjmp>    <cstdint>    <cuchar>

与 C++11 相比,为 C++14 列出了一个新的标头,即&lt;shared_mutex&gt;

注意:草案两次列出了一些标题(&lt;deque&gt;&lt;istream&gt;&lt;stdexcept&gt;&lt;unordered_set&gt;)。此外,C++11 的 5 个标头未在草案的表格中列出,即&lt;exception&gt;&lt;iterator&gt;&lt;ratio&gt;&lt;scoped_allocator&gt;&lt;thread&gt;。由于§18.8 定义&lt;exception&gt;,§24 定义&lt;iterator&gt;,§20.11 定义&lt;ratio&gt;,§30 定义&lt;thread&gt;,以及§30.4 定义&lt;shared_mutex&gt;,这就是为什么你不应该相信标准草案的例子作为最终决定——它们包含错误。

ISO/IEC 14882:2017 (C++17)

基于 2017 年 3 月 21 日草稿 N4659 的 C++17 标头临时列表。这是对第 20.5.1.2 节 Headers 中表 16 和 17 的转录。这不是最终标准;理论上,有些事情可能会改变。

有 61 个 C++ 头文件:

<algorithm>           <future>            <numeric>           <strstream>
<any>                 <initializer_list>  <optional>          <system_error>
<array>               <iomanip>           <ostream>           <thread>
<atomic>              <ios>               <queue>             <tuple>
<bitset>              <iosfwd>            <random>            <type_traits>
<chrono>              <iostream>          <ratio>             <typeindex>
<codecvt>             <istream>           <regex>             <typeinfo>
<complex>             <iterator>          <scoped_allocator>  <unordered_map>
<condition_variable>  <limits>            <set>               <unordered_set>
<deque>               <list>              <shared_mutex>      <utility>
<exception>           <locale>            <sstream>           <valarray>
<execution>           <map>               <stack>             <variant>
<filesystem>          <memory>            <stdexcept>         <vector>
<forward_list>        <memory_resource>   <streambuf>
<fstream>             <mutex>             <string>
<functional>          <new>               <string_view>

与 C++14 相比,新的标头似乎是:&lt;any&gt;&lt;execution&gt;&lt;filesystem&gt;&lt;memory_resource&gt;&lt;optional&gt;&lt;string_view&gt;&lt;variant&gt;

同样,与C(C11)相关的26个头文件与C++11和C++14相比没有变化:

<cassert>   <cinttypes>  <csignal>    <cstdio>   <cwchar>
<ccomplex>  <ciso646>    <cstdalign>  <cstdlib>  <cwctype>
<cctype>    <climits>    <cstdarg>    <cstring>
<cerrno>    <clocale>    <cstdbool>   <ctgmath>
<cfenv>     <cmath>      <cstddef>    <ctime>
<cfloat>    <csetjmp>    <cstdint>    <cuchar>

另见What are the new features in C++17?

请注意,在 C++17 中,某些“C 库”标头是 deprecated,特别是 &lt;ccomplex&gt;&lt;cstdalign&gt;&lt;cstdbool&gt;&lt;ctgmath&gt;(而不是 &lt;ciso646&gt;)。 C++ 标头 &lt;codecvt&gt;(在 C++11 中添加)在 C++17 中也已弃用。


*日期中的“推迟一年”问题是由于标准获得批准后处理该标准所需的时间。 ANSI 在1989 中批准了原始C 标准; ISO 于 1990 年批准。修正案 1 于 1994 年获得批准;它于 1995 年发布。

【讨论】:

    【解决方案2】:

    在这里试试:http://en.cppreference.com/w/

    但是,您可能还引用了操作系统的头文件。这些可以在 MSDN (Windows) 或 man 命令(POSIX 系统)上找到。如果您在其他操作系统上,或者其他来源。

    【讨论】:

      【解决方案3】:

      我发现了这个Wikipedia entry on the C standard library,其中包含C 头文件列表以及它们所属的哪个 标准的详细信息。这为您提供了一个很好的历史视角和其他一些类似的细节。

      当然,这只是 C。在“C++ 标准库”下可以找到类似的文章。这也引用了其他一些库,这些库本身可能不是“标准”的,但如果没有这些库,一些习惯于使用扩展的人会觉得 C++ 会“残废”。

      【讨论】:

        【解决方案4】:

        http://www.cplusplus.com/reference/ 列出了所有标准 C++ 头文件和 C 头文件的 C++ 包装器。

        tree.h 不是标准库的一部分。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-08-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-11-12
          相关资源
          最近更新 更多