2013-05-16 20 views
1

有沒有什麼辦法在C( C++)隱枚舉爲int(反之亦然)轉換GCC發出警告。有什麼辦法讓隱式枚舉在C中的int轉換的gcc問題警告?

我發現隱式轉換可以一點點馬虎,我花了很長一段時間跟蹤我造成了錯誤,這是與此有關。

+0

你可能想看看'Splint' http://www.splint.org/否則我不會看到一個方法。手動4.1.2節看起來有用http://www.splint.org/manual/manual.html –

+1

是不是''enum's int's? – alk

回答

0

在C沒有隱式轉換警告,因爲一個enum由語言的定義的常數int類型不是enum型的。如果你有編譯器警告在這些事情上,你將不得不在第二行警告,但不是第三:

enum things { thing };  //< declaration of a constant of type int 
enum things thingy = thing; //< implicit conversion from int to enum things 
enum things thingi = thingy; //< no conversion 
相關問題