Let's take the following example:
#include <stdio.h>
enum fruit {APPLE, ORANGE, BANANA};
enum planet {EARTH, MARS, NEPTUNE};
void foo(enum fruit f)
{
printf("%ld", f);
}
int main()
{
enum planet p = MARS;
foo(p); /* compiler doesn't complain */
return 0;
}
What's the point of enum
s having names, if that code would compile?
Here is my command line for gcc:
gcc file.c -ansi -Wall -Wextra