【IAR警告】Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined


 

Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement

 

運算符兩邊都是volatile變量的警告

 

這警告有意義.

用volatile修飾的變量一般不直接參與運算,volatile就以為着這個變量在運算過程中有可能已經改變了

例如:想計算a * b 要這樣:

volatile unsigned char a;
volatile unsigned char b;

unsigned char x,y;

x = a;
y = b;

return (x * y);


建議使用另外一個變量參與計算:

volatile char VVV = 9;

char fun()
{
char xxx;
char yyy = 9;

xxx = VVV;
return xxx * yyy
}



 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM