Created
April 26, 2018 14:06
-
-
Save sighingnow/2206245998aa2f769b4470305447a563 to your computer and use it in GitHub Desktop.
ghc treat certain kinds of warnings as errors when compile c source file.
This file contains hidden or 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
D:\Open>gcc test.c -Wall -c | |
test.c: In function 'g': | |
test.c:8:14: warning: passing argument 1 of 'f' from incompatible pointer type [-Wincompatible-pointer-types] | |
return f(cp); | |
^~ | |
test.c:1:5: note: expected 'int *' but argument is of type 'char *' | |
int f(int *a) { | |
^ | |
D:\Open>stack exec -- ghc -c test.c -Wall | |
test.c: In function 'g': | |
test.c:8:14: error: | |
warning: passing argument 1 of 'f' from incompatible pointer type [-Wincompatible-pointer-types] | |
return f(cp); | |
^~ | |
| | |
8 | return f(cp); | |
| ^ | |
test.c:1:5: error: | |
note: expected 'int *' but argument is of type 'char *' | |
int f(int *a) { | |
^ | |
| | |
1 | int f(int *a) { | |
| ^ |
This file contains hidden or 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
int f(int *a) { | |
return 1; | |
} | |
int g() { | |
char c = 'a'; | |
char *cp = &c; | |
return f(cp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment