Created
June 11, 2021 05:18
-
-
Save Costava/46b1cc76e10d7131168507163bd23ee9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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