资源描述:
《C编码风格和标准》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、UCRCS&E:ComputingSystems--IndianHillCStyleandCodingStandardsIndianHillCStandardsRecommendedCStyleandCodingStandardsL.W.CannonR.A.ElliottL.W.KirchhoffJ.H.MillerJ.M.MilnerR.W.MitzeE.P.SchanN.O.WhittingtonBellLabsHenrySpencerZoologyComputerSystemsUniversityofT
2、orontoDavidKeppelEECS,UCBerkeleyCS&E,UniversityofWashingtonMarkBraderSoftQuadIncorporatedTorontoAbstractThisdocumentisanupdatedversionoftheIndianHillCStyleandCodingStandardspaper,withmodificationsbythelastthreeauthors.Itdescribesarecommendedcodingstandardfo
3、rCprograms.Thescopeiscodingstyle,notfunctionalorganization.1.IntroductionThisdocumentisamodifiedversionofadocumentfromacommitteeformedatAT&T'sIndianHilllabstoestablishacommonsetofcodingstandardsandrecommendationsfortheIndianHillcommunity.Thescopeofthisworki
4、sCcodingstyle.Goodstyleshouldencourageconsistentlayout,improveportability,andreduceerrors.Thisworkdoesnotcoverfunctionalorganization,orgeneralissuessuchastheuseofgotos.We(seefootnote1)havetriedtocombinepreviouswork[1,6,8]onCstyleintoauniformsetofstandardsth
5、atshouldbeappropriateforanyprojectusingC,althoughpartsarebiasedtowardsparticularsystems.Ofnecessity,thesestandardscannotcoverallsituations.Experienceandinformedjudgementcountformuch.ProgrammerswhoencounterunusualsituationsshouldconsulteitherexperiencedCprog
6、rammersorcodewrittenbyexperiencedCprogrammers(preferablyfollowingtheserules).Thestandardsinthisdocumentarenotofthemselvesrequired,butindividualinstitutionsorgroupsmayadoptpartorallofthemasapartofprogramacceptance.Itisthereforelikelythatothersatyourinstituti
7、onwillcodeinasimilarstyle.Ultimately,thegoalofthesestandardsistoincreaseportability,reducemaintenance,andaboveallimproveclarity.Manyofthestylechoicesherearesomewhatarbitrary.Mixedcodingstyleishardertomaintainthanbadcodingstyle.Whenchangingexistingcodeitisbe
8、ttertoconformtothestyle(indentation,spacing,commenting,namingconventions)oftheexistingcodethanitistoblindlyfollowthisdocument.``Tobeclearisprofessional;nottobeclearisunprofessional.''--SirErnestGowers.