How to make gcc warn about passing wrong enum to a function

前端 未结 6 686
失恋的感觉
失恋的感觉 2020-11-29 10:14

gcc doesn\'t seem to produce a warning with the following code. How can I get it to produce a warning?

typedef enum
{
    REG8_A,
    REG8_B,
    REG8_C
}REG         


        
6条回答
  •  无人及你
    2020-11-29 10:39

    $ g++ test3.cpp -o test3
    test3.cpp: In function ‘int main()’:
    test3.cpp:22: error: cannot convert ‘REG16’ to ‘REG8’ for argument ‘1’ to ‘void function(REG8)’
    

提交回复
热议问题