This appendix lists many IOf 'tile' most significant differences between CS,9' and C99.

(The smaller differences are IDol numerous ,0 mention here", 'The headin .' indicate which chapter contains the prim,tt'~ discussion of . aeh C99 feature. some or the changes 3'( ibuted I~O C99 ,alcfl1,al~y occurred earlier in Amendment 1 tn the CS,9 standard: these changes are marked 'Am,e.ndIDleJlt ] .',"

II commems eg9 adds a second kind oj comment. which begins with II '"

identifiers C89 re- uires compiler to remember the _~rslt 3] characters of identifiers: in Cg5i~1 the requir-ement i -, ,63 characters, OW)' the fit! .~ lx characters of names r ih external linkage are significant in C8'9 .. Mo:reov,er. the c e of letters may not matter [111, -99" the first]1 characters are significant, and the case of letters i- taken into account,

ke¥WD~ds Five keyword are new in C99': inline,~re'st,rict" BooL, _ Com,plex, and _Imagina.ry.

rrf3tulnin'g trom main In C,891if a p .ogram reaches the end '0 the mad.n function w,~thou~x eeuting a return. st __ tement, the value returned to the op ,radng ,y' tern i 8 U ndefined, In C919" lfmaLn is, declared to return an int,~ the program returns 0 to the operating : y " m,

/ ,an'd % op1eratars The C8:9 standard stares that if either operand i negative, the result Dc au integer : ivision can be rounded em ther up or d.IIJWDj, Moreo'Ver, if i or j is negative til .. igu of i % j depends 00 the implei aentanon. In C9'91, the result of a division L always truncater toward zero and the value of i % j has [be Stille sign as, L,

5'

,

6

for state,m-enls:

'7

lang lo,ng integer t]ltpels

long I',ong ,integer cansta1nts

~ypres of'intege'f constS}M"S

hexadeclmB'1' floa;ting ,c(J'nst.s1nts

8

9

mixed deCi/8ralions ,liJlndstatem ,ent!!

In C~)9 the fus,L expression m lafor s,ILa~emel1l,can he replaced by a declaration, allowingthe tatement '~O declare its own control vari:abl,e(s,)i.

C'99 provides two additional ' tandard in~eg,er types" lO,D'S! lOID,g int and unsi'gned, long' Lonq Irrt.

In addition to the standard integer type~,~ Cg'9 allows implementation ... defined extended signed and unsigned integertypes,

C'919 provides I 'way Ito indicate tblit an integer constant l1U 'tYPiC long 10D'9 int orunsign,e,d Lonq 1010,g iD,t~

egg'! uJ jIi'. de ."'., .. L,~ f' .. . , ... ~':;,-~ . II;: iII,'~

I '_ 's I'_ _Ie-, _fIOr '_ etenmnmg tne typ~ 0 an integer constant me uiuerco,t rrom tnose

~In' ,C·.···· ~IU

'~ ' .. _ !DIY ..

The rules fUf' implicit couversions m egg are somewhat differen from [be rule in 'CSi~l" primari1y because of C9sr-'·, additional basic types,.

'C99' rapports designated initializers which can be used to initialize ::IJT,ays" strue .. tures, and unions,

ill C95l~ tile length of ;Ifl ,array may be specified by an .~ xpression that' ' DOlt constan _ pro,vided that the array doesn' t have static S Cirage du -I:' "00 and its declareIrion doesn [ contain an initializer,

If the return type of a function Jis, omitted in C89 the function is presumed to return a value of typ,e Lnt, . In C9i9 it ,SI illegal 't,c omitthe return type of a function.

In 'C'89'1 declaration mu ,t precede statements within ~ bloclc (including the bcdy 0- D function)" In C9!9'IJ deelarationsand statements can be mixed as long as eech variable '. declared prior [10 the first statementthat use ' - e variable.

dec.Js'ra'tian or rJe'fin'itian' fsquire'd' p',rtQ'r tal function Qall

va,riabJe'-le,ngth a'ffsypar:sm,s,ter,s

st,ati.c array' par:ams'ts,n;

return sta,temsl,nt' Witi1',DU',t exp,rssslDn

14

additional 'p,redefin,fJd maaros

e,tTI;pty macro ,arg,umen'ts

meaoe with al' llEJ'ria'bJe numiJ1,s(' ,(J;fs'rgumen'ts

,eg'9 requires tba[ either a declaration or a definition of a function be present prior to any call of the function, eR91 doesn't have Iltltis requirement; if a JWlC:ljoD, ] called 'without a, prior declaration or definition. the compiler I' umes that the June, ion returns ,an Lnt; value ..

1:99 allows variable .. l,ep,gtb ar.tay parameters. In a function declaration, the • symbo~ may appear inside brackets to irn,di,c'are a variable-length array parameter,

IC9'9 anows the use of the word at.at.i c in the declaration of an arf,ay parameter indicating a. minimum length for [h,c_. first dimens ion of the array,

IC99 supports the u .. e of compound literals, which allow the creation of UDll:3LlllOO array and structure values.

C99 allows main to be' declared in an implementation ... defined manner; with a TIe-tum type other 'llhan int amrlJor parameters lotbe;r dian those specified by the standard,

In 'C:8,9- executing ,3 .rlet'urn statement w itheut an expression in anon-vof.d runetiOJD. cause .. , undefined behavior (but Duly if the program attempts ('0 us e the 'value returned by he function), In C'991, such at statement is illegal,

IC99 aUow. any or all ofthe arguments, in a macro call to be empty, provided 'that the call contains the correct number of commas.

10 C8ge a macre must have a fixed number of argumenr ~ if i[ has, aII.y at all, C99' allows macros that tnke an tmlimited Dumber of arguments,

fane' ldenttfls'f In C'9'9" the ~_ func __ identifier behaves like a s,b'ing variable 'that stores the name of the currently executing unctlou.

16·

,s'tructUfel typ'e GtJfflp,stibl'ity·

III CS9,~ there are DO standard pragm:asl,. IC919' ha 'three: ex LIM.lTED RAlij'iGE" FENV A[!ICES'S; and FP CONTRACTI•

~ ~

C919 provides 'the _Pragma. operator, which is, used in, conjunction with the #pr'agm;o directive.

In C8'9- structures defined in different tiles are compati ble if their members have the samenames arnd, appear in the same order'mwitb corresponding members having

c' nnpatible type . ,- 99 al 0' require' til It eith _ r both itructures have J1C ~ ame tag Of' n ithe'" h-, a 'fa.

tralling comm'.J in In 'C'9~, til" I 1,0.1 onst ~' in an enW11" to I ion 'm_-"y be followed b ,I comma, enumerations

117 dvaneed Uses, 'f Poi' 'ters,

18

black: scopes 10'" selection and ife'fatlon stats'ments

i!rla}J: structurei and union in,;tializs,rs

in/ins' func'lions

211

:22

'. ~pr in·tf convBrs~ol,n speciffca fions

. no -, ,:', th I, - ~,' me mb r I,,', "a stru uure to be an array un p ecified l r- gth,

In ' I g,. "I ection statem ll'C I if and switch) and h.ratio t ~emlDJ . (wllille do, d ,or -'all-Il,g with [be ~ inner" ,: tat ments n hat the-,. c nlro,l-are consid ... 110

In ,'9~ brace-enclo .. ~ _ miti Iizer f If' an arra ,~' u ure, ~ -r union mu _,II', contain only constant expres 'ion I,. In 9'9, lh'~sl restriction applies nly' if the variable has i-' 3DI- . tOIJt '" hJT-, ti n,~

'The Standar:d Library'

The <stdbool" he- header, which define' L1b,~ boo.L, t rue, and false Dl8CIO ,i' n ' in '99,.

_ he c ' fl' ,eI' ion spec ifieations for [he .. ~pr'int f function hav undergon _ a number of change in IC99 \ ith ,11_ ~ length m difiers n wen ':er'lJOID specifiers the ~ bilir to rite inti nil~ dl ,:aN and uPP' rt r : id, ehara .. it r.~' I, be %" 1 e, %.lE %: 1 f %7119 I and ~! l'G onversiom W"~' le,[ta] in e99'· tirey ceu d undefined bell' "i r in ,e, ' .

In IC9'9,~ the CUll I r ton pe ification for tll" ...... scanf function - hav new ] ength modi _le,..,. new ,on el'S ion ' pee" ~ef I he abH ity ,'re' , in fjnj rand _.,' - " " nd s p= port for wide characters,

o tb-

,2:3 Lr -ra y SupplDr . for Numbersl and ',haracte Da:1a

<flcat.~, 11,> ,he,ade,{'

". f 1,0' ='iI r h - he- ade r.

'~ - ~ ~ Iii! ... LiF'"""", ,", _ '!Ir

sJt:ldltiDn'si,ma'c,ros in III _ [9', he -e Lfmi B ~ h> h a er nrain three <limit,s .h;) header chsra t ns C ofthe long Lonq Lnt; types,

maCh_errhandling mac,ro

,IJddltioneJ "unctions in -ema th '. h> h'sader

25'

I ...

" I

digraphs'

I 9'9 lSi '. imp}, mentation [ h ·i-,e of h- to inform I.' P'.fO r m that i:-n .' nor Itas 0' curred ill a m uhematical function: v j a a value . tored in lerrno, vis a fl ating ... point I il eptionc or bCU1. Th alu of the mat.h _,eTrhandl ing mac-

I defined In -cmat.h ih » lOID ate' how error are signaled by 3 parti .ul . imp lamentation.

C99 ,add· two new versions of most -cmat.h, h>, functiom 'lone for float rand on ' f r long double. e99' al, 0 adds a numb r of' completel 11'. un tion and func tion-I ike m ._,era, to -ema t.h ., h»,

Digraphs, which are t o-cher icter ymboI" that can be u sed .f '. '- ubstitntes for the

[.] { }"';" and t ' 1 kens, lar. new inC I • I Am ndrm n I"

[The <i.90646 h,> header, which defines mro that represent . peratoi '. cnntain-

in the cham 'ter &, I' -,,! WI - md ~!I is n.w in _991., ( • mendment . ,I

LJn/vre,r.s's.1 ch,sra'[c,te[r . niver " . .11 char 'IC·. r name: hich p:1J I ide a ¥l~l.~· to ern ied l r S charae in th .

n'am'88 ". ource code 0:' a program, are ne . in . 91 r,

~wchar" h> h'eader Th - <w'char h> h ader, ID-b pr\ ide un ri n. er id "" h "3,cter input/output aJnd wide sumg manipulation, is new in IC9'9~ Amendment I)

<·W',ct·YP'I:!. h> heaJjer Th <'wc'typ,e .. , h~ he d . .[- th wi I -~: haria '_ r version 0' ~c'type" h», j: ne in

e99. <;'w>c'tyP·e" h:> provides functi' ns I _ or 1.8S" . if-yrng and ch angi ug th _ case of

~ id _ ch _ ~ r ter '" (Amendment 1 1

va_copy,ma'Cro 'C9'9r add, a func tion-like macro n rru d 'va~ copy Lathe -c s'tdarg ~ h» header,

a;ddittanal fun'ctions In C'9 'I add' [he V'B np.r in t jf:l vf ac a n f v·s c arif', and va 6, eanf functions to . h _ <: stdic ;; b,:> beeaer <: 8, tdi.o . h» h ader,

additiona[1 fun'clions in I'. 99 add;' five numeric conver ion function ''I ~h __ Exit functio _ and lang l,clng <:stdlib,.h:> beeder ver i. n Or the abe d div function [0 tho <,st,dlJ.,b .h> head r,

B'dditiona,i strftime '. 9<,' adds 8 .numher ofnew strftime con [ T ion IP' ~,cifi rs It ,;]:',0 an W the .. _ GonVrs.rsio'tl,sp·eclfiers of an E or 10 char cter te modi . the meanins f Ice' " _ C O\f.eli in . pecif :_r' .

·<stdin,t. h> hSt.Jder TJ11e ,<stdint" h» header whi,e'h d, zlare inte ter Iyp -. with, PI- cified widths, is new in ~ '9E

complex types e9g provide 0; three compk ".' ~pe":-,: float ~Colmpl.ex. doub Le _Complex and Lonq dounLe _ €!Iolmp 1 ex.

<co,mp,lex~,h> header he -e comp.l ex" h> header, hich provid functi ns tha per orm m d1 °DU", ·aJl

operations on cornple numbers, i , n -VI in ,C9r9.,

.c::t'gm.ath, .ib,:> neeaer he <tgmath @ h> head r, which proi i:_ ,'i Itype-gl: n eric macro tbat m __ te it e ier

t I call Ilbrary function in emat.h, h» and <complex" hs. is new ]n'9.

<·f env .. I'll> hes'de,' The < f env . h» header which gi e programs acces to '£1 satin -point tatus fk: ,g . . , nd control D10dIf!.· . L 0,'-'" in 1._ 99.

Sign up to vote on this title
UsefulNot useful