enum type check in C/gcc

前端 未结 6 971
小鲜肉
小鲜肉 2020-12-03 03:19

See the simple example below. When a function returning one enum is assigned to a variable of a different enum I don\'t get any warning even with <

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 04:04

    Probably most of us understand the underlying causes ("the spec says it must work"), but we also agree that this is a cause of a lot of programming errors in "C" land and that the struct wrapping workaround is gross. Ignoring add-on checkers such as lint, here's what we have:

    gcc (4.9): No warning available.
    microsoft cl (18.0): No warning available.
    clang (3.5): YES -Wenum-conversion
    

提交回复
热议问题