GCC - shouldn't a warning be issued when assigning an int to a char?

前端 未结 6 2012
你的背包
你的背包 2020-12-19 05:47

I\'ve recently set up a MinGW + MSYS environment on my laptop to check how things are with Netbeans C/C++ support. Everything seems to work fine, however, during my testing

6条回答
  •  甜味超标
    2020-12-19 06:14

    You're looking for

    -Wconversion
    

    You'd have to ask a gcc developer for the specific reasons why some warnings aren't included in -Wall or -Wextra.

    Anyway, these are the flags I use:

    -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations -Wshadow
    -Wpointer-arith -Wcast-align -Wwrite-strings -Wredundant-decls -Wnested-externs
    -Winline -Wno-long-long -Wconversion -Wstrict-prototypes
    

    As other's have pointed out, the behaviour of -Wconversion changed with version 4.3 - the old warning about prototypes forcing a type conversion is now available as -Wtraditional-conversion.

提交回复
热议问题