MISRA ×÷Ϊ¹¤Òµ±ê×¼µÄC±à³Ì¹æ·¶
MISRA--×÷Ϊ¹¤Òµ±ê×¼µÄC±à³Ì¹æ·¶(ǶÈëʽc¿ª·¢Õ߱ضÁ)
MISRA--×÷Ϊ¹¤Òµ±ê×¼µÄC±à³Ì¹æ·¶
MISRA (The Motor Industry Software Reliability Association
Æû³µ¹¤ÒµÈí¼þ¿É¿¿ÐÔÁª»á)
ÊÇλÓÚÓ¢¹úµÄÒ»¸ö¿ç¹úÆû³µ¹¤ÒµÐ»á£¬Æä³ÉÔ±°üÀ¨Á˴󲿷ÖÅ·ÃÀÆû³µÉú²úÉÌ¡£ÆäºËÐÄʹÃüÊÇΪÆû³µ¹¤ÒµÌṩ·þÎñºÍÐÖú£¬°ïÖú³§·½¿ª·¢°²È«µÄ¡¢¸ß¿É¿¿ÐÔµÄǶÈëʽÈí
¼þ¡£Õâ¸ö×éÖ¯×î³öÃûµÄ³É¹ûÊÇËùνµÄMISRA C Coding
Standard£¬ÕâÒ»±ê×¼ÖаüÀ¨ÁË127ÌõCÓïÑÔ±àÂë±ê×¼£¬Í¨³£ÈÏΪ£¬Èç¹ûÄܹ»ÍêÈ«×ñÊØÕâЩ±ê×¼£¬ÔòÄãµÄC´úÂëÊÇÒ׶Á¡¢¿É¿¿¡¢¿ÉÒÆÖ²ºÍÒ×ÓÚά»¤µÄ¡£×î½ü
ºÜ¶àǶÈëʽ¿ª·¢Õ߶¼ÒÔMISRA
CÀ´ºâÁ¿×Ô¼ºµÄ±àÂë·ç¸ñ£¬±ÈÈçÖøÃûµÄuC/OS-II¾ÍµÃÒâµØÐû³Æ×Ô¼º99£¥×ñÊØMISRA±ê×¼¡£¶ø¡¶Ç¶Èëʽ¿ª·¢ÔÓÖ¾¡·Ò²×¨ÃÅÔØÎĺÅÕÙ´ó¼Òѧϰ¡£±àÂë¹æ·¶
ͨ³£ÊÇÒ»¸ö¹«Ë¾×Ô¶¨µÄ“ÍÁÕþ²ß”£¬¾ÓÈ»ÓÐÈËÈ¥×ö±ê×¼£¬¶øÇÒ»¹µÃµ½¹ã·ºµÄÈÏ¿É£¬Õâ²»½ûÒýÆðÎÒÇ¿ÁÒµÄÐËȤ¡£¿ÉϧÕâ·Ý±ê×¼µÄÎı¾ÐèÒª»¨Ç®È¥Âò£¬¶øÇҶ̶̼¸Ê®Ò³£¬
Òª¼Û·Ç³£°º¹ó¡£MISRAÔÚÍøÉϹ«²¼ÁËһЩÎĵµ£¬ÆäÖÐÓйØÓÚMISRA C Coding
StandardµÄClarification±¨¸æ£¬´ÓÖмäÄã¿ÉÒÔ´óÖ²µ½MISRA±ê×¼±¾ÉíÊÇʲô¡£ÎÒ×ÐϸÔĶÁÁËÕâЩÎĵµ£¬²¢ÇÒͨ¹ýÔĶÁÆäËûһЩ½éÉÜÐÔ
Îĵµ£¬´óÖÂÁ˽âÁËMISRA±ê×¼µÄÖ÷ÒªÄÚÈÝ¡£ÕâЩÌõ¿îÈ·ÓйýÈËÖ®´¦£¬¶ÔÓÚC/C++ÓïÑÔ¹¤³ÌÏîÄ¿µÄ´úÂëÖÊÁ¿¹ÜÀíÄܹ»Æðµ½Á¼ºÃµÄÖ¸µ¼ÐÔ×÷Ó㬶ÔÓڴ󲿷ÖÈí¼þ
¿ª·¢ÆóÒµÀ´Ëµ£¬ÔÚMISRAµÄ»ù´¡ÉÏÊʵ±Ð޸ľͿÉÒÔÐγÉ×Ô¼ºµÄ¹æ·¶¡£µ±È»ÆäÖÐÒ²ÓÐһЩ¹ýÓÚÑÏ¿ÁµÄ¶«Î÷£¬Õâ¾ÍÐèÒª¸÷¸ö¿ª·¢²¿ÃÅÁé»î´¦ÀíÁË¡£ÎÒ¸öÈ˵ÄÌå»á£¬±à
Âë¹æ·¶ËäÈ»ºÜ¼òµ¥£¬µ«ÊÇÒªÍêÈ«Ö´ÐУ¬²»ÕÛ²»¿Û£¬ÐèÒª¿ª·¢²¿ÃÅÓкܸߵÄ×éÖ¯ÐԺͼÍÂÉÐÔ£¬²¢ÇÒÓкܺõĴúÂëÆÀÉó»úÖÆ¡£Òò´Ë£¬Èç¹ûÄܹ»ÑϸñµØ×ñÊرàÂë¹æ·¶£¬±¾Éí
¾ÍÊÇÒ»¸ö¿ª·¢²¿ÃÅʵÁ¦µÄÖ¤Ã÷¡£
ÕâÀï²»¿ÉÄܽ«ËùÓйæÔòÒ»Ò»Áгö£¨ÊÂʵÉÏÕýʽÎı¾ÎÒÒ»ÌõҲû¿´µ½£©£¬Ö»ÁгöһЩ±È½ÏÓÐÒâ˼µÄÌõ¿î£¬Èôó¼ÒÓлú»áÁ˽âMISRAµÄ·ç¸ñ¡£¾ßÌåµÄÄÚÈÝ£¬¸ÐÐËȤµÄÅóÓÑ¿ÉÒÔ×Ô¼ºµ½www.misra.org.ukÈ¥Á˽⡣
Rule 1. Ñϸñ×ñÑANSI C89±ê×¼£¬²»ÔÊÐíÈκÎÀ©Õ¹¡£
Rule 3. Èç¹ûҪǶÈë»ã±àÓïÑÔ£¬Ôò±ØÐ뽫ËùÓлã±àÓï¾ä°ü×°ÔÚCº¯ÊýÀ¶øÇÒÕâЩº¯ÊýÖÐÖ»Óлã±àÓï¾ä£¬Ã»Óг£¹æCÓï¾ä¡£
Rule 7. ²»µÃʹÓÃÈýÔª²Ù×÷·û£¨? : )
Rule 10. ²»µÃ²ÐÁô±»×¢Ê͵ôµÄ·Ï´úÂë¡£
Rule 11. ËùÓбêʶ·û²»³¬¹ý31×Ö·û¡£
Rule 12. ²»Í¬Ãû¿Õ¼äÖеı
Ïà¹ØÎĵµ£º
֮ǰµÄ¶¨Î»¿ÉÄÜÖ÷ҪΪÁËÑо¿µ×²ã¼°Ò»Ð©½Ï¸´ÔÓµÄÎÊÌâÉÏ£¬¶øºöÂÔÁËһЩ³õѧµÄÅóÓÑ¡£µ¼ÖÂËûÃÇ¿ÉÄÜÒ»½øÀ´¾ÍÓеã“Íû¶øÉúη”µÄ¸Ð¾õ£¨×ÔÚ¼Á˹þ£¬ÅÄש£¡£©¡£Ó¦¹ÖÊÞȺÀïÐֵܼ°Ò»Ð©ÅóÓѵĽ¨Ò飬ͬʱҲΪÁË°Ñ×Ô¼ºµÄ¾Ñé¼°±à³Ì·½ÃæµÄһЩÏë·¨·ÖÏí¸ø´ó¼Ò¡£Òò´Ë´òËãдһЩCC++ÓïÑÔ»ù´¡ÈëÃŵIJ©ÎÄ¡£
´Ó±¾Ä£¿éÖУ¬´ó¼Ò¿ÉÒÔÁ˽â ......
http://sculibin.bokee.com/5628909.html
1.ÒýÑÔ
¡¡¡¡±¾ÎĵÄд×÷Ä¿µÄ²¢²»ÔÚÓÚÌṩC/C++³ÌÐòÔ±ÇóÖ°ÃæÊÔÖ¸µ¼£¬¶øÖ¼ÔÚ´Ó¼¼ÊõÉÏ·ÖÎöÃæÊÔÌâµÄÄÚº¡£ÎÄÖеĴó¶àÊýÃæÊÔÌâÀ´×Ô¸÷´óÂÛ̳£¬²¿·ÖÊÔÌâ½â´ðÒ²²Î¿¼ÁËÍøÓѵÄÒâ¼û¡£
¡¡¡¡Ðí¶àÃæÊÔÌâ¿´ËƼòµ¥£¬È´ÐèÒªÉîºñµÄ»ù±¾¹¦²ÅÄܸø³öÍêÃÀµÄ½â´ð¡£ÆóÒµÒªÇóÃæÊÔÕßдһ¸ö×î¼òµ¥µÄstrcpyº¯Ê ......
http://www.teecool.com/post/2007081104.html
ÄÚÈÝÕªÒª£º1.д³öÅжÏABCDËĸö±í´ïʽµÄÊÇ·ñÕýÈ·, ÈôÕýÈ·, д³ö¾¹ý±í´ïʽÖÐ aµÄÖµ(3·Ö)
int a = 4;
(A)a += (a++); (B) a += (++a) ;(C) (a++) += a;(D) (++a) += (a++);
¹Ø¼ü´Ê£ºCÓïÑÔÃæÊÔÌâ C++ÃæÊÔÌâ »ªÎªÃæÊÔÌâ
±¾ÎĵØÖ·£ºhttp:// ......
CºÍÖ¸Õëѧϰ±Ê¼Ç £¨1£©
µÚ¶þÕ »ù±¾ÖªÊ¶
»·¾³£º·ÖΪ·ÒëºÍÖ´ÐÐ2¸ö¹ý³Ì¡£ÆäÖзÒë¿ÉÒÔÀí½âΪÊÇÒ»¸ö´Ó³ÌÐò—Ä¿±ê´úÂë—Á´½ÓÆ÷µÄ¹ý³Ì¡£±àÒë¹ý³ÌÓУº
1Ô¤´¦ÀíÆ÷£º´¦Àí#define #includeÕâÒ»Àà´úÂëµÄ¹ý³Ì£»
2Ô´´úÂë½âÎö£º²úÉú´íÎóºÍ¾¯¸æ£»
3ÓÅ»¯Æ÷£ºÓÐÀûÓÚÓÅ»¯´úÂ룬Ìá¸ßЧ ......
´Óprintf̸¿É±ä²ÎÊýº¯ÊýµÄʵÏÖ ×ªÌù
ÔÎÄ×÷ÕߣºÈÖÑÇÐÂ
ÕªÒª£ºÒ»Ö±ÒÔÀ´¶¼¾õµÃprintfËƺõÊÇcÓïÑÔ¿âÖй¦ÄÜ×îÇ¿´óµÄº¯ÊýÖ®Ò»£¬²»½öÒòΪËüÄܸñʽ»¯Êä³ö£¬¸üÔÚÓÚËüµÄ²ÎÊý¸öÊýûÓÐÏÞÖÆ£¬Òª¼¸¸ö¾Í¸ø¼¸¸ö£¬À´Õß²»¾Ü¡£printfÕâÖÖ¶Ô²ÎÊý¸öÊýºÍ²ÎÊýÀàÐ͵ÄÇ¿´óÊÊÓ¦ÐÔ£¬ÈÃÈ˲úÉúÁ˶ÔËü½øÐÐ̽Ë÷µÄŨºñÐËȤ¡£
¹Ø¼ü×Ö£ºprintf, ¿É±ä²ÎÊ ......