Skip to content

Instantly share code, notes, and snippets.

@Costava
Created June 11, 2021 05:18
Show Gist options
  • Save Costava/46b1cc76e10d7131168507163bd23ee9 to your computer and use it in GitHub Desktop.
Save Costava/46b1cc76e10d7131168507163bd23ee9 to your computer and use it in GitHub Desktop.
/*
* Example compilation:
* gcc enum_no_warnings.c -std=c99 -Wall -Wextra -Wconversion
*/
enum food {
BANANA = 1,
CARROT = 2,
ORANGE = 3
};
enum food foobar(enum food f) {
if (f == BANANA) {
return ORANGE;
}
/* No warning for returning non-enum value */
return 77;
}
int main(void) {
/* No warning for passing non-enum argument */
foobar(55);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment