標(biāo)題: 搞定Warning[Pa082]: undefined behavior: the order of volatile accesses is und... [打印本頁]

作者: heicad    時間: 2014-5-20 16:02
標(biāo)題: 搞定Warning[Pa082]: undefined behavior: the order of volatile accesses is und...
今天搞定了一個小錯誤,使用IAR編譯時使用2個volatile變量在同一語句時出如下警告
Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement

查資后得知原因是:volatile變量一般使用在多線程等場合,如果同一語句使用2個此變量,會出現(xiàn)訪問順序不可預(yù)知的后果,所以要解決此問題可以把其中一個先讀取存放到一個局部變量中,再和另一個進(jìn)行運算.





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1