ImageVerifierCode 换一换
格式:PDF , 页数:52 ,大小:3.52MB ,
资源ID:12502448      下载积分:12 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/12502448.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(编程语言C与C++的不兼容性.pdf)为本站上传会员【曲****】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

编程语言C与C++的不兼容性.pdf

1、Generated by Foxit PDF Creator Foxit Software For evaluation only.Incompatibilities Btwn ISO C and By David R.Tribbl Revision 1.0,2001-08-05 ContentsIntroduction C+versus C Changes to C99 versus C+98 Aggregate 工nitializrs CommentsConditional xprssion dclarations Digraph punctuation tokens Implicit f

2、unction dclarations Implicit variable dclarations 工ntrmixd dderations and statmnts C99 versus C+98Altrnat punctuation token spllings Array parameter qualifiers Boolan typ Character literals clog identifier Comma operator results Complx floatingpoint type Compound literals const linkag Dsignatd initi

3、alizers Duplicate typedefs Dynamic sizof valuation Empty paramtr listsEmpty preprocessor function macro arguments Enumration constantsEnumration declarations with trailing commaISO C+ISO C与工SO C+间的不兼容 原著 David R.Tribble Cao_julians 译 Leidan 校(VI.0)1.0 版,2001-08-05 内容引言C+与 CC99的改动与C+98 聚集的初始化子 注释 条件表

4、达式声明 连字符标记 隐含函数声明 隐含变量声明 交叉的声明和语句C99 与 C+98可选的符号标记拼写数组参数限定符布尔类型字面字符clog标识符逗号操作符结果复数浮点类型复合字面字常量链接 指定的初始化 重复的类型定义 动态sizeof运算 空预处理函数宏实参 空预处理函数宏实参 枚举常量 带后缀逗号枚举声明Generated by Foxit PDF Creator Foxit Software For evaluation only.Enumeration typsFlxibl array mmbrs Function nam mangling Function pointersHxa

5、dcimal floating-point literals IEC 60559 arithmtic support 工nlin functions Integer types headers Library function prototypes Library hadr fils long long integer typeNstd structure tagsNon-prototyp function dclarations Old-styl casts One dfinition rule _Pragma keyword Prdfind idntifirsRsrvd keywords

6、in C99 Rsrvd keywords in C+restrict keyword Returning void static linkage String initializrs String literals ar const Structures dclard in function prototyps Hyp一gnric math functions Typedefs vrsus type tagsVariable-argument function dclaratorsVariabl一argumnt preprocessor function macros Variable-le

7、ngth arrays Void pointer assignments Wide character type枚举类型灵活数组成员(FAMs)函数名分解 函数指针十六进制浮点数字面值 IEC 60559算术支持 inline函数integer类型头文件 库函数原型库头文件long long int 类型 嵌套的结构标记 非原型的函数声明 旧式风格的类型转换 一次定义规则_Pragma关键字 予定义的标识符 C99中的保留字 C+中的保留字 Restrict关键字 返回 void 静态链接 字符串初始化 字符串是常量在函数原型中声明的结构 泛型数学函数typedef与类型标记 可变参数函数声明

8、 可变参数予处理函数宏 可变长度数组 void指针赋值 宽字符类型Generated by Foxit PDF Creator Foxit Software For evaluation only.IntroductionTh C programming language Ngan to be standardizd som tim around 1985 by th ANSI X3J9 committ.Several yars of effort wnt by,and in 198 9 ANSI approved th nw standard.An ISO committ ratifid i

9、t a yar latr in 19 90 after adding an amndmnt dealing with internationalization issues.Th 1989 C standard is known officially as ANSI/ISO 9899-1989,Programming Languages C,and this document refers to the 198 9 C standard as C89.The 1990 ISO revision of the standard is known officially as ISO/IEC 989

10、9-1990,Programming Languages-C,which is rfrrd to in this documnt as C90.The nxt version of th C standard was ratified by ISO in 1999.Officially know as ISO/IEC 9899-1999,Programming Languags C,it is rfrrd to in this document as”C99”.引言大约1985年由ANSI X3J9委员会对C程序设计语言 进行标准化。多年努力后,1989年ANS工核定了新标准。一年后也就是19

11、90年ISO委员会在追加了某些更正后以 国际化版本形式批准了它。1989年C标准被官方称作 ANSI/ISO 9899-1989,C程序设计语言,本文中涉及到 1989年C标准的称之为C89ol990年该标准的工SO修订 版被官方称作工SO/工EC9899-1999,C程序设计语言,本 文中称之为C90.C标准的下一个版本199 9年由工SO批准。官方称作 ISO/IEC9899-1999,C程序设计语言,本文中称之为 C99.The C+programming languag was based on th C programming languag as it xistd shortly

12、aftr th ANSI C standardization ffort had begun.Around 1995 an ISO committee was formd to standardiz C+,and the new standard was ratified in 1998,which is officially known as ISO/IEC 14882-1998f Programming Languags-C+.It is referred to in this documnt as C+98”or simply as C+”.Though th two languags

13、shar a common hritag,and though the dsigners involvd in th standardization procsss for ach language tried to kp thm as compatible as possible,som incompatibilities unavoidably aros.Once the programmr is aware of these potential problem spots,thy are asy,for th most part,to avoid whn writing C cod.C+

14、程序设计语言是基于C程序设计语言的,在致力 于ANSI C标准后不久就产生了 C+。大约1995年成立 了标准C+的工S。委员会,新标准在1998年被批准,官 方称作工SO/工EC14882-1998,C+程序设计语言。本文 称N 为 C+9 8 或 C+。尽管这两种语言有着相同的传统,尽管这两个语言标 准化过程的设计者都尽可能保持它们的兼容性,然而某些 不兼容还是无可奈何地出现。但是程序员知道了这些潜在 的问题,他们在写C代码时会很容易避开它们。Generated by Foxit PDF Creator Foxit Software For evaluation only.Whn we s

15、ay that C is incompatibl with C+with rspct to a spcific languag Mature,w man that a C program that mploys that fatur ithr is not valid C+cod and thus will not compil as a C+program,or that it will compil as a C+program but will exhibit diffrnt behavior than the sam program compiled as a C program.In

16、 othr words,an incompatible C fatur is valid as C cod but not as C+cod.All incompatibilities of this kind ar addrssd in this document.Avoiding ths kinds of incompatibilities allows the programmer to write correct C code that is intndd to interact with,or be compiled as,C+code.Another form of incompa

17、tibl fatur is one that is valid whn used in a C+program but is invalid in a C program.W call this an incompatible C+Mature.Hug portions of th C+languag fall into this catgory(e.g.,classs,tmplats,exceptions,rfrances,mmbr functions,anonymous unions,tc.),so vry fw of ths kinds of incompatibilities ar a

18、ddressed in this documnt.Yet another form of incompatible fatur occurs whn a C+program uses a Mature that has the sam name as a C90 datura but which has a different usage or meaning in C.This document covrs ths kinds of incompatibilities.当我们考虑某个特定的语言特点时说C与C+不兼容,意味着采用这个特点的c代码不是一个有效的C+代码、并且不能作为C+程序进行编

19、译,或者作为C+程序编译 会出现与作为c程序编译不同的效果。换句话说,作为C 有效的不兼容的特性,对C+无效。在本文中强调所有这 类不兼容性。特别是当它与C+代码相互作用时,或当它 被作为C+代码编译时,避免这类不兼容性可使程序员写 出正确的C代码,。另一形式的不兼容性是用于C+程序中是正确的,而 在c程序中是无效的。我们称之为C+不兼容性。C+程 序设计语言中的大部分(如类,模板,异常,引用,成员 函数,匿名共用体等等)具有这类性质,所以本文很少强 调这类不兼容性。然而还有另一形式的不兼容性,当C+程序中使用一个特性,它在c程序中有相同的名字但有不 同的用途或不同的意义。本文会涉及到这类不兼

20、容性。This document lists only th incompatibilities between C99 and C+98.(Incompatibilities between C90 and C+have bn documntd Iswhr;sAppndix B of Stroustrup STR,for xampl.)Naw additions to th C99 standard library ar also not addrssd in this document uniss thy specifically introduce C+incompatibilities

21、C+vrsus CAs discussd in th Introduction,no attempt is made in this documnt to covr incompatibl C+Matures,i.,daturas of the C+language or library that ar not supported in C.Hug portions of C+and its library fall into this category.A partial list of ths daturas includes:本文只列出了 C99和C+98之间的不兼容性。(C90 和C

22、的不兼容性在别的文章中提及过,如见 Stroustrup 的附录 B)本文也不强调新加入的C99标准库,除非它们特别地 引入了 C+的不兼容性。C+与 C正如在引言中讨论的,本文不想讨论C+的不兼容性,即在C中不支持的C+语言或C+库中那部分特性。C+语言或库中大部分属于这一类。这些性质包括在下表中:Generated by Foxit PDF Creator Foxit Software For evaluation only.anonymous unions classes constructors and dstructors xcptions and try/catch blocks

23、 xtrnal function linkages(e.g.,xtrn C)function overloading mmbr functions namespaces new and delete operators and functions oprator overloading rfrnc types standard tmplat library(STL)template classs template functionsChanges to C99 versus C+98Th following items ar incompatibilities btwn C90 and C+9

24、8,but have since been changd in C99 so that they no longr cause problms btwn the two languags.Aggrgat工nitializrsC90 rquires automatic and rgistr variables of aggrgat type(structr array,or union)to have initializers containing only constant expressions.(Many compilers do not adhr to this restriction,

25、however.)C99 removes that restriction,allowing non-constant xprssions to b used in such initializrs.C+allows non-constant xprssions to be used in initializrs for automatic and register variabls.(It also allows arbitrary non-constant xprssions to b usd to initializ static and xtrnal variabls.)匿名共用体类构

26、造函数和析构函数异常和抛出/捕捉块外部函数链接(如xtrn“C部函数重载成员函数名字空间nw和delete操作符和函数操作符重载引用类型标准模板库(STL)模板类模板函数C99的改动与C+98下述项目在C90和C+98间是不兼容的,但从C99 开始它们不再会在两种语言间引起问题。聚集的初始化C90要求聚集类型(结构、数组或共用体)的自动变 量和寄存器变量只能用常量表达式初始化。(然而,许多编 译器并不坚持这个限制)C99撤消了这一限制,允许非常量表达式用于此类初 始化。C+允许非常量表达式用于自动变量和寄存器变量的 初始化。(它也允许任意的非常量表达式用于静态变量和外 部变量的初始化。)Gen

27、erated by Foxit PDF Creator Foxit Software For evaluation only.For xampl:/C and C+cod void foo(int i)例如/C and C+cod void foo(int i)floatx=/.(float)i;/Valid C90,C99,andC+intm3=2,3);/./ValidC90,C99,andC+intg2=o.i;/Invalid C90)C99:6.7.8C+98:3.7.2,8.5,8.5.1floatx=(float)i;/C90,C99,and C+有效intm3=1,2,3);/

28、C90,C99,and C+有效intg2=o,/C90无效i);Commnts注释C+recognizes/comments as well as/*/commnts.C+识另U/注释和/*/注释。C90 only rcognizs th/*.*/form of commnts.The II、form usually produces a syntax rror in C90,but thr ar rare cass that may compile erroneously without warning:C90仅识别/*。*/形式的注释。C90对/形式通常 产生一个语法错误,但很少会出现无

29、警告而错误编译的。i=(x/*y*/z+r w);C99 recognizes both forms of comments.C99:5.1.1.2,6.4.9C+98:2.1,2.7Conditional xprssion dclarationsC+allows local variabl dclarations within conditional xprssions(which appar within for,if,whil,and switch statmnts).The scope of the variables dclard in this context xtnds to t

30、h end of the statmnt containing the conditional expression.For example:i=(x/*y*/z+,w);C99识别两种形式的注释条件表达式声明C+允许局部变量声明出现在条件表达式中(出现在 for,if,while,和switch语句中)。在这个上下文中 声明的变量其作用域扩展到包含这个条件表达式的语句尾 部。例如:Generated by Foxit PDF Creator Foxit Software For evaluation only.for(int i=0;i SIZE;i+)a i=i+1;C90 dos not

31、 allow this fatur.C99 allows this fatur,but only within for statmnts.C99:6.8.5 C+98:3.3.2,6.4,6.5for(int i=0;i SIZE;i+)a i=i+1;C90不允许这个性质。C99允许这个性质,但仅仅在这个for语句中。Digraph punctuation tokensC+rcognizs two-character punctuation tokens,calld digraphs,which ar not rcognizd by C90.Th digraphs and thir quiv

32、alnt tokens ar:)%:*%:%:#C99 recognizes th same set of digraphs.The following program is valid in both C99 and C+:%:includ stdio.h%:ifndef BUFSIZE%:dfin BUFSIZE 512%:endif void copy(char dr const char sr int len)%whil(1n=0)%:1n:=s%C99:6.4.6连字符标记C+识别两个字符的标记,称为连字符,C90不能识 别。连字符与其等价的符号如下 )%:*%:%:#C99能识别这

33、个连字符集合。下述程序在C99和C+中都是有效的:%:include%:ifndf BUFSIZE%:define BUFSIZE 512%:endifvoid copy(char df const char s:,int 1n)=0)%d=s;%Generated by Foxit PDF Creator Foxit Software For evaluation only.C+98:2.5,2.12Implicit function declarationsC90 allows a function to b implicitly dclard at th point of its fir

34、st use(call)r assigning it a return typ of int by default.For example:/*No previous dclaration of bar()is in scop*/void foo(void)(bar();/*Implicit declaration:xtrn int bar()*/a隐含函数声明C90允许一个函数在它的第一个使用(调用)点隐含 声明,缺省地指定为int返回类型。例如:/*在这个作用域内没有事先声明bar()*/*隐含声明:外部的int bar()*/C+dos not allow implicit functi

35、on declarations.It is invalid to call function that dos not hav a previous dclaration in scop.C99 no longer allows functions to b implicitly dclard.The cod above is invalid in both C99 and C+.C+不允许隐含函数声明。在作用域内没有事先声明 就调用函数是无效的。C99不再允许隐含声明函数。上述代码在C99和C+中都是无效的。C99:6.5.2.2C+98:5.2.2Implicit variabl decl

36、arationsC90 allows the dclaration of a variabl,function argument,or structure mmbr to omit th type spcifir,implicitly(faulting its type to int.C99 does not allow this omission,and nithr dos C+.The following cod is valid in C90,but invalid in C99 and C+:static sizes=0;/*Implicit int,rror*/struct info

37、 const char*name;const sz;/*Implicit intr error*/);隐含变量声明C90允许变量、函数形参或结构体成员省略类型指定 符,隐含它(们)的类型是int。C99不允许这种省略,C+也不允许。下述代码在C90中有效,但在C99和C+中无效:static sizs=0;/*隐含 int,错误*/struct info(const char*name;const sz;/*隐含 int,错误*/);Generated by Foxit PDF Creator Foxit Software For evaluation only.static foo(rgis

38、tr i)/*Implicit ints,rror*/(auto j=3;/*Implicit int,rror*/return(i+j);C99:6.7,6.7.2C+98:1,7.1.5static foo(rgistr i)/*隐含 int,错误*/(auto j=3;/*隐含 int,错误*/return(i+j);工ntrmixd declarations and statementsC90 syntax spcifis that all the dclarations within a block must appar bfor the first statement in th

39、block.交叉的声明和语句C90语法限定一个块中的所有声明必须早于块中的第 一个语句。C+dos not hav this restriction,allowing statmnts and dclarations to appar in any order within a block.C99 also rmovs this rstriction,allowing intermixed statements and declarations.void prefind(void)(int i;for(i=0;i SZ;i+)if(find(arri)brak;const char*s;/*I

40、nvalid C90,valid C99 and C+*/s=arri;prepend(s);C99:6.8.2C+98:6,6.3,6.7C+没有这个限制,允许一个块中的语句和声明以任 何顺序出现。C99也撤消了这个限制,允许交叉的语句和声明。void prefind(void)(int i;for(i=0;i SZ;i+)if(find(arri)brak;const char*s;/*工C90中无效,C99和C+中有效*/s=arr i;prpnd(s);Generated by Foxit PDF Creator Foxit Software For evaluation only.C

41、99 vrsus C+98C99 与 C+98Th following items comprise th diffrncs btwn C99 and C+98.Some of th s incompatibilities xist d b tw n C8 9 and C+98 and remain unchanged btwn C99 and C+98,whil others ar new daturas that wr introduced into C99 that are incompatibl with C+98.Not that features that ar specific

42、to C+and which are not 1gal C(.g.,class mmbr function declarations)are not included in this section;only language features that ar common to both C and C+ar discussd.Most of the features are valid as C but invalid as C+.下述项目包括了 C99和C+98间的差别。有一些不 兼容性在C89和C+98中就存在,并保留到C99和 C+98,然而其它一些新引入C99的性质也与C+98不

43、兼容。注意一些在C中不合法的C+性质(如类成员函数 声明)并不包括在这里;只讨论C和C+共有的语法性质。这些性质大部分在C中是有效的,但在C+中是无效的。Som of ths faturs ar likely to b implmntd as xtnsions by many C+compilers in ordr to b more compatibl with C compilers.Altrnat punctuation tokn spellingsC+provids the following keywords as synonyms for punctuation tokens:8.

44、nd&and_eq&=bitand&bitor|compl not!not_q!=or|or_q|=xor A xorqq A=Ths keywords ar also recognized by th C+preprocessor.C90 dos not have these built-in keywords,but it does provide a standard header fil that contains dfinitions for th sam words as macros,bhaving almost like built-in keywords.某些性质或许是由许多

45、C+编译器实现的扩展,为与 C编译器更多地兼容。可选的符号标记拼写C+提供下述关键字作为符号标记的同义词。and&and_eq&=bitand&bitor|compl not!not_ q!=or|or_eq|=xor A xorqq A=C+预处理器也识别这些关键字。C90没有这些内建的关键字,但提供了一个标准的 is0646.h头文件,包含了这些词的宏定义,表现为 有这些内建关键字。Generated by Foxit PDF Creator Foxit Software For evaluation only.C+rquires implmntations to provid an mp

46、ty hadr.Including it in a C+program has no ffct on the program.Howvr,C cod that do s not includ the h ad r is free to use th s words as idntifirs and macro nairas,which may caus incompatibilities when such cod is compile1 as C+.num oper nop,and,or,q,ne;xtrn int instr(num opr op,struct compl*c);Th rc

47、ommndd practice for cod intndd to b compild as both C and C+is to use ths idntifirs only for these special manings,and only after including./Propr hadr inclusion allows for the us of*and*t al#ifndef _cplusplus include int foo(float a,float b,float c)(return(a b and b=c);C99:7.9C+98:2.5,2.11Array par

48、ameter qualifiersC99 provids nw declaration syntax for function paramtrs of array types,allowing type qualifiers(the cv-qualifiers const and volatil,and restrict)to be includd within th first set of brackets of an array declarator.The qualifier modifies th type of th array paramter itself.For xampl,

49、the following dclarations ar semantically idntical:extern void foo(int strconst);xtrn void foo(int*const str);In both declarations,paramtr str is a const pointr to an int object.C+需要提供一个空的1$。646.4头文件来实现。在C+程序中包含它没有效果。然而,C代码中不包含这 个头文件去作为标识符和宏名字使用,将在C+中编译时 引起不兼容性。enum opr nop,and,or,eqA ne;extern int instr(num oper op,struct compl*c);仅在这些特定意义上使用这些标识符,而且仅在包含 了is0646.h头文件之后,这个被推荐的实践有意于代 码象C和C+一样被编译,。/正确的头文件包含允许-nd,等的使用#ifndf cplusplus#includ ndifint foo(float a,float b,float c)(return(a b and b=c);数组参数限定符C99为数组类型的函数参数提供了新的声明语法,允 许类型限定符(cv限定符const,volatile和 restrict)被包括在数组声明符的第一组括号内。

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服