Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ghc treat certain kinds of warnings as errors when compile c source file.
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) {
| ^
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