什么是C和C ++标准之间的关系? [英] What is the Relationship Between the C and C++ Standards?

查看:261
本文介绍了什么是C和C ++标准之间的关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写<一个href=\"https://stackoverflow.com/questions/5539249/why-transforms-begin-s-end-s-begin-tolower-cant-be-complied-successfu/37438120#37438120\">this回答我从<带引号的href=\"http://en.cp$p$pference.com/w/cpp/string/byte/tolower#Parameters\">http://en.cp$p$pference.com/w/cpp/string/byte/tolower#Parameters


  

不重presentable为unsigned char和不等于EOF,这种行为是未定义


当我去检查<一个href=\"http://en.cp$p$pference.com/mwiki/index.php?title=cpp%2Fstring%2Fbyte%2Ftolower&diff=66149&oldid=65953\">the这又增加了这句话我发现编辑,作者的评论:


  

不能使用负号的字符,每个C99的任何文件ctype.h函数7.4 / 1


笔者是从C ++文档C99标准引用。是有效的?我找不到在C ++标准这个函数的定义任何东西,所以我必须假定它是有效的。

但是,这涉及到我有2个原因:


  1. 我怎么知道是什么版本C标准的C ++标准取决于?

  2. 还有的<一个列表href=\"http://programmers.stackexchange.com/questions/16390/what-are-the-fundamental-differences-between-c-and-c\">the C和C ++到处之间的差异。如果我期待在参照C中的标准C ++我怎么可能知道我在寻找该地区已被覆盖?


解决方案

对于第一个问题:

C ++标准明确列出了C标准(S),它依赖于它的规范性引用文件的部分。对于C ++ 14,[intro.refs] 1.2 / 1恰好C组99:


  

      
  • ISO / IEC 9899:1999,的编程语言与MDASH; ç

  •   
  • ISO / IEC 9899:1999 / Cor.1:2001(E)的编程语言与MDASH; C,技术勘误1

  •   
  • ISO / IEC 9899:1999 / Cor.2:2004(E)的编程语言与MDASH; C,技术勘误2

  •   
  • ISO / IEC 9899:1999 / Cor.3:2007(E)的编程语言与MDASH; C,技术勘误3

  •   

对于第二个问题:

C ++标准不会隐结合的任何的C标准的部分;对C标准的所有引用是明确的。信息在何处C ++从C偏离的良好来源是附件C,C ++标准的兼容性,尤其是C.1 [diff.iso]

此外,对C标准库引用分散在整个C ++标准库的描述(章17 ndash的; 30在C ++ 14)。特别感兴趣的可以是:


  • 17.2 LIBRARY.C],它描述了C标准库的基本纳入

  • 第18章[language.support],它描述了许多&LT的装置; c :::&GT;标准库的C ++ 头(那些提供C标准库功能)。

I was writing this answer and I quoted from http://en.cppreference.com/w/cpp/string/byte/tolower#Parameters

Is not representable as unsigned char and does not equal EOF, the behavior is undefined

When I went to inspect the edit that had added this phrase I found that the author's comment:

Can't use negative signed chars with any ctype.h function per C99 7.4/1

The author is citing from the C99 standard in C++ documentation. Is that valid? I couldn't find anything on the definition of this function in the C++ standard, so I must assume that it is valid.

But this concerns me for 2 reasons:

  1. How would I know what version of the C standard the C++ standard depends upon?
  2. There are lists of the discrepancies between C and C++ everywhere. If I'm looking at the C standard with reference to C++ how could I possibly know whether the area I'm looking at has been overridden?

解决方案

For the first question:

The C++ standard explicitly lists the C standard(s) on which it depends in its Normative references section. For C++14, [intro.refs] 1.2/1 happens to list C 99:

  • ISO/IEC 9899:1999, Programming languages — C
  • ISO/IEC 9899:1999/Cor.1:2001(E), Programming languages — C, Technical Corrigendum 1
  • ISO/IEC 9899:1999/Cor.2:2004(E), Programming languages — C, Technical Corrigendum 2
  • ISO/IEC 9899:1999/Cor.3:2007(E), Programming languages — C, Technical Corrigendum 3

For the second question:

The C++ standard does not implicitly incorporate any parts of the C standard; all references to the C standard are explicit. A good source of information on where C++ deviates from C is Annex C, "Compatibility" of the C++ standard, particularly C.1 [diff.iso].

Additionally, references to the C standard library are scattered throughout the description of the C++ standard library (chapters 17–30 in C++14). Of particular interest can be:

  • 17.2 [library.c], which describes the basic inclusion of the C standard library
  • Chapter 18 [language.support], which describes many of the <c:::> headers of the C++ standard library (those which offer the C standard library functionality).

这篇关于什么是C和C ++标准之间的关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆