愉快而富有成效。 有效。 8你要使你的程序的目的和结构清晰。 男人使用One True Brace Style,即使你喜欢它也不会因为你的创造力更好地用于解决问题而不是 创造了美丽的新阻碍理解。 不能同意更多! 9你的外部标识符在前六个字符中应该是唯一的,虽然这种严厉的纪律令人厌烦,而且它的必要年代在你看似没有结束之前伸展,但是你要撕掉你的头发 out and mad mad在那个命运的日子里,当你想要在一个旧系统上运行你的程序时。 这些天有点生疏。具有此限制的系统通常不具有标准C实现的。但是,除了通用的 图书馆需要自己的名字空间之外,规则相对容易 跟随。 10你要穿衣服,放弃,并放弃邪恶的异端邪说,这就是所有的世界都是VAX,并且没有商业合作。 坚持这种野蛮信仰的愚昧的异教徒,即使你当前的机器时间很短,你的计划可能会很长。 s / VAX / Windows PC 所以,大部分都幸免于难。应该增加一个强调便携式编程重要性的新项目。还有另一个因为混淆C和C ++并且不鼓励用C ++编译器编写的C代码编写的b $ b。但是我对国王完全没有能力 詹姆斯的英语,所以我不打算写他们;-) Dan Dan - Dan Pop DESY Zeuthen,RZ集团 电子邮件: Da*****@ifh.de Okay, forgive me if this has come up before, but I didn''t find anything inGoogle Groups.I ran accross an old printed copy of the 10 Commandments for C Programmers alittle while back, and it got me thinking: "Gee, these are beginning to showtheir age. I wonder what the folks on c.l.c would suggest by way of revision?"So, if you were to produce a Revised 10 Commandments for C Programmers, whatwould you add? What would you remove? What would you change?Grant D. Watson gr**********@yahoo.pleasedontspamme.com (Use this one!) 解决方案1. Never assume anything2. See 1.Are you aware of the "Annotated Edition?" http://www.lysator.liu.se/c/ten-commandments.html-- Er*********@sun.comLet''s look at them:1 Thou shalt run lint frequently and study its pronouncements withcare, for verily its perception and judgement oft exceed thine.gcc -Wall -O and compilers with similar diagnosing capabilities removethe need for lint. So, the validity of this commandment depends on yourcompiler.2 Thou shalt not follow the NULL pointer, for chaos and madness awaitthee at its end.s/NULL/null3 Thou shalt cast all function arguments to the expected type if theyare not of that type already, even when thou art convinced that thisis unnecessary, lest they take cruel vengeance upon thee when thouleast expect it.Valid for variadic functions only.4 If thy header files fail to declare the return types of thy libraryfunctions, thou shalt declare them thyself with the most meticulouscare, lest grievous harm befall thy program.Obsolete.5 Thou shalt check the array bounds of all strings (indeed, allarrays), for surely where thou typest ``foo'''' someone someday shalltype ``supercalifragilisticexpialidocious''''.More valid than ever.6 If a function be advertised to return an error code in the event ofdifficulties, thou shalt check for that code, yea, even though thechecks triple the size of thy code and produce aches in thy typingfingers, for if thou thinkest ``it cannot happen to me'''', the godsshall surely punish thee for thy arrogance.Valid.7 Thou shalt study thy libraries and strive not to reinvent themwithout cause, that thy code may be short and readable and thy dayspleasant and productive.Valid.8 Thou shalt make thy program''s purpose and structure clear to thyfellow man by using the One True Brace Style, even if thou likest itnot, for thy creativity is better used in solving problems than increating beautiful new impediments to understanding.Couldn''t agree more!9 Thy external identifiers shall be unique in the first six characters,though this harsh discipline be irksome and the years of its necessitystretch before thee seemingly without end, lest thou tear thy hairout and go mad on that fateful day when thou desirest to make thyprogram run on an old system.A bit rusty these days. The systems with this limitation usually don''thave standard C implementations. However, except for general purposelibraries that need their own name space, the rule is relatively easy tofollow.10 Thou shalt foreswear, renounce, and abjure the vile heresy whichclaimeth that ``All the world''s a VAX'''', and have no commerce withthe benighted heathens who cling to this barbarous belief, that thedays of thy program may be long even though the days of thy currentmachine be short.s/VAX/Windows PCSo, most of it survived with little changes. A new item emphasising theimportance of portable programming should probably be added. And anotheragainst confusing C and C++ and discouraging the writing of C code thatcompiles with C++ compilers. But I''m completely incompetent on KingJames'' English, so I''m not going to write them ;-)DanDan--Dan PopDESY Zeuthen, RZ groupEmail: Da*****@ifh.de 这篇关于10诫,修订的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-06 13:24