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
The only way I can see of generating a warning is if you are prepared to pass pointers rather than bare enums, e.g.
typedef enum
{
REG8_A,
REG8_B,
REG8_C
} REG8;
typedef enum
{
REG16_A,
REG16_B,
REG16_C
} REG16;
void function(REG8 * reg8)
{
}
int main(void)
{
REG16 r = REG16_A;
function(&r);
return 0;
}
Not exactly an elegant solution, but it does give a warning, at least with gcc -Wall:
$ gcc -Wall warn_enum.c -o warn_enum
warn_enum.c: In function ‘main’:
warn_enum.c:23: warning: passing argument 1 of ‘function’ from incompatible pointer type
$