在哪里可以找到当前的 C 或 C++ 标准文档? [英] Where do I find the current C or C++ standard documents?
问题描述
对于许多问题,答案似乎都在标准"中.然而,我们从哪里找到呢?最好是在线的.
谷歌搜索有时会让人感到徒劳,尤其是对于 C 标准,因为它们淹没在编程论坛上的大量讨论中.
首先,因为这些是我现在正在搜索的,所以哪里有好的在线资源:
- C89
- C99
- C11
- C++98
- C++03
- C++11
- C++14
- C++17
PDF 版本标准
截至 2014 年 9 月 1 日 2021 年 9 月,PDF 格式的官方 C 和 C++ 标准文档的最佳价格位置似乎是:
C++20 – ISO/IEC 14882:2020:198 CHF(约217 美元)来自 iso.org
C++17 – ISO/IEC 14882:2017:$90新西兰标准局提供的新西兰元(约 65 美元)
C++14 – ISO/IEC 14882:2014:$90新西兰标准局提供的新西兰元(约 65 美元)
C++11 – ISO/IEC 14882:2011:60 美元来自 ansi.org 或 来自 Techstreet 的 60 美元
C++03 – INCITS/ISO/IEC 14882:2003:$30 来自ansi.org
C++98 – ISO/IEC 14882:1998:$80新西兰标准局提供的新西兰元(约 60 美元)
C17/C18 – INCITS/ISO/IEC 9899:2018:116 美元来自 INCITS/ANSI/N2176/c17_updated_proposed_fdis.pdf2017 年 11 月的草稿(链接已断开,请参阅 Wayback Machine N2176)
C11 – ISO/IEC 9899:2011:
$30$60,来自 ansi.org/WG14 草案版本 N1570C99 – INCITS/ISO/IEC 9899-1999(R2005):$60 来自ansi.org/WG14 草案版本 N1256
C90 – ISO/IEC 9899:1990:90 新西兰元(约65 美元)来自新西兰标准组织
标准的非 PDF 电子版本
- C89 – ANSI 文本格式的草案版本:(https://web.archive.org/web/20161223125339/http://flash-gordon.me.uk/ansi.c.txt)
- C89 – 作为 HTML 文档的草稿版本:(http://port70.net/~nsz/c/c89/c89-draft.html)
- C90 TC1;ISO/IEC 9899 TCOR1,单页 HTML 文档:(http://www.open-std.org/jtc1/sc22/wg14/www/docs/tc1.htm)
- C90 TC2;ISO/IEC 9899 TCOR2,单页 HTML 文档:(http://www.open-std.org/jtc1/sc22/wg14/www/docs/tc2.htm)
标准的印刷版本
标准的印刷副本可从国家标准机构和 ISO 获得,但非常昂贵.>
如果您想要一份 C90 标准的硬拷贝,但价格比上面少得多,您可以找到一份便宜的 Herb Schildt 的书 带注释的 ANSI 标准 Amazon,其中包含标准的实际文本(有用)和对标准的评论(不太有用 - 它包含几个危险和误导性的错误).
C99 和 C++03 标准可从 Wiley 和 BSI(英国标准协会)获得书籍形式:
标准委员会草案版本(免费)
未来标准的工作草案通常可从委员会网站获得:
如果您想从当前或更早的 C/C++ 标准中获取草稿,可以在互联网上免费获得一些草稿:
对于 C:
ANSI X3.159-198 (C89):我找不到 C89 的 PDF,但它与 C90 几乎相同.唯一的主要区别在于样板和章节编号,尽管有一些轻微的文本差异
ISO/IEC 9899:1990 (C90):(几乎与 ANSI X3.159-198 (C89) 相同,除了前面的内容和部分编号.第 6.5.7 节(以前是 3.5.7)中至少有一个文本差异,其中 a list" 变成了一个大括号括起来的列表".注意ANSI 和ISO/IEC 标准之间的转换是在这个文档里面看到的,该文档将它的名字称为ANSI/ISO": 9899/99"虽然这不是后来制定的标准的正确名称,但正确的名称是ISO/IEC 9899:1990")
C90 的 TC1:http://www.open-std.org/jtc1/sc22/wg14/www/docs/n423.pdf
WG14 网站,遗憾.
ISO/IEC 9899:1999(C99 包含所有三个技术勘误表):http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
早期版本的 C99 仅包含 TC1 和 TC2:http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
原始(即更正前)C99 的工作草案:http://www.open-std.org/jtc1/sc22/wg14/www/docs/n843.htm (HTML) 和 http://www.dkuug.dk/JTC1/SC22/WG14/www/docs/n843.pdf (PDF).请注意,后来有两个工作草案:N869 和 N878,但它们似乎已从 WG14 网站上删除,因此这是可用的最新版本.
C89/C90 和 C99 之间的变化列表:http:///port70.net/~nsz/c/c89/c9x_changes.html
C99 的 TC1(只有 TC,不是包含它的标准):http://www.open-std.org/jtc1/sc22/wg14/www/docs/9899tc1/n32071.PDF
C99 的 TC2(只有 TC,不是包含它的标准):http://www.open-std.org/jtc1/sc22/wg14/www/docs/9899-1999_cor_2-2004.pdf
ISO/IEC 9899:2011 (C11):http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
ISO/IEC 9899:2011/Cor 1:2012(C11 的唯一技术勘误表):可在 https://www.iso.org/obp/ui/#iso:std:iso-iec:9899:ed-3:v1:cor:1:v1:en 但无法下载.这是实际的更正,而不是草稿.
ISO/IEC 9899:2018 (C17/C18):https://web.archive.org/web/20181230041359if_/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf (N2176)>
C2x 正在进行中 - 截至 2020 年 10 月 18 日的最新工作草案 (N2731):http://www.open-std.org/JTC1/SC22/WG14/www/docs/n2731.pdf
对于 C++:
ISO/IEC 14882:1998 (C++98):http://www.lirmm.fr/~ducour/Doc-objets/ISO+IEC+14882-1998.pdf
ISO/IEC 14882:2003 (C++03):https://cs.nyu.edu/courses/fall11/CSCI-GA.2110-003/documents/c++2003std.pdf
ISO/IEC 14882:2011 (C++11):http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf
ISO/IEC 14882:2014 (C++14):https://github.com/cplusplus/draft/blob/master/papers/n4140.pdf?raw=true
ISO/IEC 14882:2017 (C++17):http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf
ISO/IEC 14882:2020 (C++20):https:///isocpp.org/files/papers/N4860.pdf
ISO/IEC 14882:2023(C++23 正在进行中.工作草案日期为 2021 年 3 月 17 日):http://open-std.org/JTC1/SC22/WG21/docs/papers/2021/n4885.pdf>
请注意,这些文件与标准不同,尽管会议之前决定标准的版本通常与最终标准中的版本非常接近.FCD(最终委员会草案)版本受密码保护;您需要加入标准委员会才能获得它们.
尽管草案版本可能与标准的最终批准版本非常接近,但本文的一些编辑强烈建议您获取实际文档的副本 - 特别是如果您打算引用它们作为参考.当然,如果手头拮据,饥饿的学生应该继续使用汇票.
看来,如果您愿意并能够在标准批准后等待几个月,搜索INCITS/ISO/IEC"而不是ISO/IEC"当寻找标准是关键.通过这样做,本文的一位编辑能够以合理的价格找到 C11 和 C++11 标准.例如,如果您搜索INCITS/ISO/IEC 9899:2011"而不是ISO/IEC 9899:2011"在 webstore.ansi.org 上,您会找到价格合理的 PDF 版本.
站点 https://wg21.link/ 提供了指向 C++ 当前工作草案的短 URL 链接和标准草案和委员会文件:
- https://wg21.link/std11 - C++11
- https://wg21.link/std14 - C++14
- https://wg21.link/std17 - C++17
- https://wg21.link/std20 - C++20
- https://wg21.link/std - 当前工作草案
该标准的当前草案在 Github 上作为 LaTeX 源进行维护.这些来源可以使用 cxxdraft-htmlgen 转换为 HTML.以下站点维护如此生成的 HTML 页面:
Tim Song 还维护生成的 HTML 和 PDF 版本的网络 TS 和范围 TS.
POSIX 对 C 标准的扩展
POSIX 标准 (IEEE 1003.1) 要求兼容的操作系统包含 C 编译器.该编译器又必须符合 C 标准,并且还必须支持系统接口"中定义的各种扩展.POSIX 的部分(例如 off_t
数据类型、
标头、clock_gettime()
函数和 _POSIX_C_SOURCE
宏.)
因此,如果您尝试查找特定函数,被告知该函数是 POSIX 的一部分,而不是 C 标准",并且想知道为什么操作系统标准强制要求编译器功能和语言扩展...现在你知道了!
POSIX.1-2001:系统接口部分可以作为单独的文档从 https://mirror.math.princeton.edu/pub/oldlinux/download/c951.pdf.第 1.7 节指出 C 标准的相关版本是 C99.
外壳和实用程序"部分(https://mirror.math.princeton.edu/pub/oldlinux/download/c952.pdf) 不仅要求存在符合 C99 的编译器,而且还要求可以从命令行以c99"的名称调用它.可以实现这一点的一种方法是将名为c99"的 shell 脚本放置在在/usr/bin 中,它调用 gcc 并将
-std=c99
选项添加到命令行参数列表中,并阻止指定任何竞争标准.POSIX.1-2001 有两份技术勘误表,一份是 2002 年的,另一份是 2004 年的.我认为它们没有被合并到上面链接的文档中.https://pubs.opengroup.org/onlinepubs/009695399/有一个包含勘误表的在线 HTML 版本 - 但我应该补充一点,我在搜索框方面遇到了一些问题,因此使用 Google 搜索该网站可能是您最好的选择.
https://standards.ieee.org/standard/1003_1-2001-Cor1-2002.html.
https://standards.ieee.org/standard/1003_1-2001-Cor2-2004.html
http://www.open-std.org/jtc1/sc22/open/n4217.pdf.
POSIX.1-2008 也有两个技术勘误,两个中的后一个是 2016 年的.在 https://pubs.opengroup.org/onlinepubs/9699919799.2016edition/ - 不过,我也遇到过网站自己的搜索框没有的情况非常适合查找信息.
POSIX.1-2017 的在线 HTML 版本位于 https://pubs.opengroup.org/onlinepubs/9699919799/ - 不过,我再次建议使用谷歌而不是该网站的搜索框.根据 Open Group 网站,IEEE 1003.1-2017 ...是对 1003.1 的修订-2008 标准汇总标准,包括其两个技术勘误表(原样)".Linux 联机帮助页 将其描述为技术上相同";POSIX.1-2008 应用技术勘误表 1 和 2.因此,这不是重大修订,并且不会更改
_POSIX_C_SOURCE
宏的值.
For many questions the answer seems to be found in "the standard". However, where do we find that? Preferably online.
Googling can sometimes feel futile, again especially for the C standards, since they are drowned in the flood of discussions on programming forums.
To get this started, since these are the ones I am searching for right now, where are there good online resources for:
- C89
- C99
- C11
- C++98
- C++03
- C++11
- C++14
- C++17
PDF versions of the standard
As of 1st September 2014 September 2021, the best locations by price for the official C and C++ standards documents in PDF seem to be:
C++20 – ISO/IEC 14882:2020: 198 CHF (about $217 US) from iso.org
C++17 – ISO/IEC 14882:2017: $90 NZD (about $65 US) from Standards New Zealand
C++14 – ISO/IEC 14882:2014: $90 NZD (about $65 US) from Standards New Zealand
C++11 – ISO/IEC 14882:2011: $60 from ansi.org or $60 from Techstreet
C++03 – INCITS/ISO/IEC 14882:2003: $30 from ansi.org
C++98 – ISO/IEC 14882:1998: $80 NZD (about $60 US) from Standards New Zealand
C17/C18 – INCITS/ISO/IEC 9899:2018: $116 from INCITS/ANSI / N2176 / c17_updated_proposed_fdis.pdf draft from November 2017 (Link broken, see Wayback Machine N2176)
C11 – ISO/IEC 9899:2011:
$30$60 from ansi.org / WG14 draft version N1570C99 – INCITS/ISO/IEC 9899-1999(R2005): $60 from ansi.org / WG14 draft version N1256
C90 – ISO/IEC 9899:1990: $90 NZD (about $65 USD) from Standards New Zealand
Non-PDF electronic versions of the standard
- C89 – Draft version in ANSI text format: (https://web.archive.org/web/20161223125339/http://flash-gordon.me.uk/ansi.c.txt)
- C89 – Draft version as HTML document: (http://port70.net/~nsz/c/c89/c89-draft.html)
- C90 TC1; ISO/IEC 9899 TCOR1, single-page HTML document: (http://www.open-std.org/jtc1/sc22/wg14/www/docs/tc1.htm)
- C90 TC2; ISO/IEC 9899 TCOR2, single-page HTML document: (http://www.open-std.org/jtc1/sc22/wg14/www/docs/tc2.htm)
Print versions of the standard
Print copies of the standards are available from national standards bodies and ISO but are very expensive.
If you want a hardcopy of the C90 standard for much less money than above, you may be able to find a cheap used copy of Herb Schildt's book The Annotated ANSI Standard at Amazon, which contains the actual text of the standard (useful) and commentary on the standard (less useful - it contains several dangerous and misleading errors).
The C99 and C++03 standards are available in book form from Wiley and the BSI (British Standards Institute):
- C++03 Standard on Amazon
- C99 Standard on Amazon
Standards committee draft versions (free)
The working drafts for future standards are often available from the committee websites:
If you want to get drafts from the current or earlier C/C++ standards, there are some available for free on the internet:
For C:
ANSI X3.159-198 (C89): I cannot find a PDF of C89, but it is almost the same as C90. The only major differences are in the boilerplate and section numbering, although there are some slight textual differences
ISO/IEC 9899:1990 (C90): (Almost the same as ANSI X3.159-198 (C89) except for the frontmatter and section numbering. There is at least one textual difference in section 6.5.7 (previously 3.5.7), where "a list" became "a brace-enclosed list". Note that the conversion between ANSI and ISO/IEC Standard is seen inside this document, the document refers to its name as "ANSI/ISO: 9899/99" although this isn't the right name of the later made standard of it, the right name is "ISO/IEC 9899:1990")
TC1 for C90: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n423.pdf
There isn't a PDF link for TC2 on the WG14 website, sadly.
ISO/IEC 9899:1999 (C99 incorporating all three Technical Corrigenda): http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
An earlier version of C99 incorporating only TC1 and TC2: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
Working draft for the original (i.e. pre-corrigenda) C99: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n843.htm (HTML) and http://www.dkuug.dk/JTC1/SC22/WG14/www/docs/n843.pdf (PDF). Note that there were two later working drafts: N869 and N878, but they seem to have been removed from the WG14 website, so this is the latest one available.
List of changes between C89/C90 and C99: http://port70.net/~nsz/c/c89/c9x_changes.html
TC1 for C99 (only the TC, not the standard incorporating it): http://www.open-std.org/jtc1/sc22/wg14/www/docs/9899tc1/n32071.PDF
TC2 for C99 (only the TC, not the standard incorporating it): http://www.open-std.org/jtc1/sc22/wg14/www/docs/9899-1999_cor_2-2004.pdf
ISO/IEC 9899:2011 (C11): http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
ISO/IEC 9899:2011/Cor 1:2012 (C11's only technical corrigendum): This can be viewed at https://www.iso.org/obp/ui/#iso:std:iso-iec:9899:ed-3:v1:cor:1:v1:en but cannot be downloaded. It is the actual corrigendum, not a draft.
ISO/IEC 9899:2018 (C17/C18): https://web.archive.org/web/20181230041359if_/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf (N2176)
C2x work-in-progress - latest working draft as of 18th October 2020 (N2731): http://www.open-std.org/JTC1/SC22/WG14/www/docs/n2731.pdf
For C++:
ISO/IEC 14882:1998 (C++98): http://www.lirmm.fr/~ducour/Doc-objets/ISO+IEC+14882-1998.pdf
ISO/IEC 14882:2003 (C++03): https://cs.nyu.edu/courses/fall11/CSCI-GA.2110-003/documents/c++2003std.pdf
ISO/IEC 14882:2011 (C++11): http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf
ISO/IEC 14882:2014 (C++14): https://github.com/cplusplus/draft/blob/master/papers/n4140.pdf?raw=true
ISO/IEC 14882:2017 (C++17): http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf
ISO/IEC 14882:2020 (C++20): https://isocpp.org/files/papers/N4860.pdf
ISO/IEC 14882:2023 (C++23 work-in-progress. Working draft dated March 17 2021): http://open-std.org/JTC1/SC22/WG21/docs/papers/2021/n4885.pdf
Note that these documents are not the same as the standard, though the versions just prior to the meetings that decide on a standard are usually very close to what is in the final standard. The FCD (Final Committee Draft) versions are password protected; you need to be on the standards committee to get them.
Even though the draft versions might be very close to the final ratified versions of the standards, some of this post's editors would strongly advise you to get a copy of the actual documents — especially if you're planning on quoting them as references. Of course, starving students should go ahead and use the drafts if strapped for cash.
It appears that, if you are willing and able to wait a few months after ratification of a standard, to search for "INCITS/ISO/IEC" instead of "ISO/IEC" when looking for a standard is the key. By doing so, one of this post's editors was able to find the C11 and C++11 standards at reasonable prices. For example, if you search for "INCITS/ISO/IEC 9899:2011" instead of "ISO/IEC 9899:2011" on webstore.ansi.org you will find the reasonably priced PDF version.
The site https://wg21.link/ provides short-URL links to the C++ current working draft and draft standards, and committee papers:
- https://wg21.link/std11 - C++11
- https://wg21.link/std14 - C++14
- https://wg21.link/std17 - C++17
- https://wg21.link/std20 - C++20
- https://wg21.link/std - current working draft
The current draft of the standard is maintained as LaTeX sources on Github. These sources can be converted to HTML using cxxdraft-htmlgen. The following sites maintain HTML pages so generated:
- Tim Song - Current working draft - C++11 - C++14 - C++17 - C++20
- Eelis - Current working draft
Tim Song also maintains generated HTML and PDF versions of the Networking TS and Ranges TS.
POSIX extensions to the C standard
The POSIX standard (IEEE 1003.1) requires a compliant operating system to include a C compiler. This compiler must in turn be compliant with the C standard, and must also support various extensions defined in the "System Interfaces" section of POSIX (such as the off_t
data type, the <aio.h>
header, the clock_gettime()
function and the _POSIX_C_SOURCE
macro.)
So if you've tried to look up a particular function, been informed "This function is part of POSIX, not the C standard", and wondered why an operating system standard was mandating compiler features and language extensions... now you know!
POSIX.1-2001: The System Interfaces section can be downloaded as a separate document from https://mirror.math.princeton.edu/pub/oldlinux/download/c951.pdf. Section 1.7 states that the relevant version of the C standard is C99.
The "Shell and Utilities" section (https://mirror.math.princeton.edu/pub/oldlinux/download/c952.pdf) mandates not only that a C99-compliant compiler should exist, but that it should be invokable from the command line under the name "c99". One way in which this can be implemented is to place a shell script called "c99" in /usr/bin, which calls gcc with the
-std=c99
option added to the list of command-line parameters, and blocks any competing standards from being specified.POSIX.1-2001 had two technical corrigenda, one dated 2002 and one dated 2004. I don't think they're incorporated into the documents as linked above. There's an online HTML version incorporating the corrigenda at https://pubs.opengroup.org/onlinepubs/009695399/ - but I should add that I've had some trouble with the search box and so using Google to search the site is probably your best bet.
There is a paywalled link to download the first corrigendum at https://standards.ieee.org/standard/1003_1-2001-Cor1-2002.html.
There is also a paywalled link for the second at https://standards.ieee.org/standard/1003_1-2001-Cor2-2004.html
There is a draft version of POSIX.1-2008 at http://www.open-std.org/jtc1/sc22/open/n4217.pdf.
POSIX.1-2008 also had two technical corrigenda, the latter of the two being dated 2016. There is an online HTML version of the standard incorporating the corrigenda at https://pubs.opengroup.org/onlinepubs/9699919799.2016edition/ - though, again, I have had situations where the site's own search box wasn't good for finding information.
There is an online HTML version of POSIX.1-2017 at https://pubs.opengroup.org/onlinepubs/9699919799/ - though, again, I recommend using Google instead of that site's searchbox. According to the Open Group website "IEEE 1003.1-2017 ... is a revision to the 1003.1-2008 standard to rollup the standard including its two technical corrigenda (as-is)". Linux manpages describe it as "technically identical" to POSIX.1-2008 with Technical Corrigenda 1 and 2 applied. This is therefore not a major revision and does not change the value of the
_POSIX_C_SOURCE
macro.
这篇关于在哪里可以找到当前的 C 或 C++ 标准文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!