misra c 笔记2

更新时间:2023-07-04 14:46:00 阅读: 评论:0

60  The right hand operand of a logical && or || operator shall not contain side effects.
如下面的代码不是允许的:
[cpp] view plain copy
 
1. if ( ( a == 3 ) && b++ ) 
2.
3.         c = 1; 
4.  } 
5.  if ( ( a == 3 ) || b++ ) 
6.  { 
7.        c = 1; 
8.   } 
9.    if ( ( a == 3 ) || func33 (  ) ) 
10.    { 
11.         c = 1; 
12.
苏联入侵阿富汗61  The operands of a logical && or || shall be primary-expressions.
用”()” 显示说明每一个优先级.
 
 
62  The operands of logical operators (&&, || and !) should be effectively Boolean. Expressions that are effectively Boolean should not be ud as operands to operators oth
er than (&&, || and !).
 
63  bitwi operators shall not be applied to exprands who underlying type is signed
 
64  The right hand operand of a shift operator shall lie between zero and one less than the width in
bits of the underlying type of the left hand operand.
 
 
65  The unary minus operator shall not be applied to an expression who underlying type is unsigned.
莴苣的做法
读书心得格式模板 
66  The comma operator shall not be ud.
gta5多少内存 
67  Evaluation of constant unsigned integer  expressions should not lead to wrap-around.
 
68  The underlying bit reprentations of floatingpoint values shall not be ud.
 
69  The increment (++) and decrement (--) operators should not be mixed with other operators in an
expression.
经常在网上或书上看到类似于下面的题目:
x = y+++z; x = ?
看到misra-c标准后, 我不由的感叹:这个世界还有很多有意义的事等着我们程序员去做.
 
70  Assignment operators shall not be ud in expressions that yield a Boolean value
如:
[cpp] view plain copy
 
1. if ( ( a = b ) != 0 ) 
2.  { 
3.         c = 1; 
4.  } 
电脑什么牌子好


71  Tests of a value against zero should be made explicit, unless the operand is effectively Boolean.
 
72  Floating-point expressions shall not be tested for equality or inequality.
 
73  The controlling expression of a for statement shall not contain any objects of floating type.
 
74  The three expressions of a for statement shall be  concerned only with loop control
 
75  Numeric variables being ud within a for loop for iteration counting shall not be modified in the
body of the loop.强大的
 
76  Boolean operations who results are invariant shall not be permitted.
 
77  There shall be no unreachable code.
 
78  All non-null statements shall either :
a) have at least one side-effect however
executed, or
b)    cau control flow to change.
 
79  Before preprocessing, a null statement shall only occur on a line by itlf; it may be followed by a comment provided that the first character following the null statement is a white space character.
 
78和79的意思是
非空语句必须要么产生副作用( side-effect) (副作用是指表达式执行后对程序运行环境造成的影响。赋值语句、自 增操作等都是典型的具有副作用的操作。) ;或者使程序流程改变。 例如,下面的代码是不允许的: ? x > = 3 ;
错误在于x 和3 比较的结果被丢弃了
80  The goto statement shall not be ud.
 
81  The continue statement shall not be ud.
 
82  For any iteration statement there shall be at most  one break statement ud for loop termination.
 
83  A function shall have a single point of exit at the end of the function.
 
84  The statement forming the body of a switch, while, do ... while or for statement shall be a
compound statement.
 
85  An if (expression) construct shall be followed by a compound statement. The el keyword shall be
followed by either a compound statement, or another if statement.
84和85的意思是 if,while等语句要加括号
 
86  All if … el if constructs shall be terminated with  an el clau.
 
87  A switch label shall only be ud when the most cloly-enclosing compound statement is the body of a switch statement.(switch语句的主体要有括号)
 
88  An unconditional break statement shall terminate  every non?empty switch clau.
梯子简笔画 
89  The final clau of a switch statement shall be the default clau.
 
90  A switch expression shall not reprent a value  that is effectively Boolean.
 
91  Every switch statement shall have at least one  ca clau.
 
92  Functions shall not be defined with a variable number of arguments.
如下面的代码是不允许的
static void rule69 ( SC_8 *fmt, ... ) ;
 
93  Identifiers shall be given for all of the parameters  in a function prototype declaration
 
94  The identifiers ud in the declaration and  definition of a function shall be identical.
也用英语怎么写 
95  Functions with no parameters shall be declared  with parameter type void.
 
96  The number of arguments pasd to a function  shall match the number of parameters.
 
97  All exit paths from a function with non-void return type shall have an explicit return sta
tement with

本文发布于:2023-07-04 14:46:00,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1078091.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:副作用   语句   类似
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图