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

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

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





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