2017.08.03
linux下gcc3.4.5下編譯通過(guò)好的含goto語(yǔ)句c程序,goto跳轉(zhuǎn)到end
使用gcc4.8.2 遇上一下錯(cuò)誤提示
error: jump to label ‘end’
error: from here
error: crosses initialization of ‘int x’
error: crosses initialization of ‘int y’
gcc4.8.2在跳轉(zhuǎn)之后還有變量聲明的話,它認(rèn)為后面定義的變量在跳轉(zhuǎn)label定義時(shí)尚未初始化,故而編不過(guò)去
把所有的變量聲明放到第一個(gè)goto跳轉(zhuǎn)之前就行。