|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2008-4-25 00:41:42
|
显示全部楼层
后在各网站搜索了下,有如下回答:
'volatile' indicates that the value of a variable can change at any
>time and without the knowledge of the compiler. When you compare two
>volatiles, both have to be read in order to do the comparison and one
>or the other will be read first. However, one or both values could
>change after reading the first and before reading the second. The
>compiler is warning the order in which they are read can have an
>impact upon the results of the comparison and the order is undefined
That makes no sense because the iar compilers don't know restricted
varables and they treat every variable as a volatile variable. Therefore
that warning should arise at every comparison of two variables.
Because the iar compilers treat every variable as a volatile variable
the source code needs does not need the volatile qualifier. This is the
reason why you have to declare all variables, which are modified by ISRs
or schedules processes, as volatile when you port to other compilers
like gcc/mspgcc.
The ANSI standard says that these two different compiler behaviors are
allowed although they are not compatible.
如果是volatile的问题的话那可能是一行中同时出现了两个以上volatile,编译器不知道先去访问哪个物理对象是你的设计本意.
因为多个变量都要求编译器立马访问物理地址.这种警告不必理会. |
|