C - gcc: assignment from incompatible pointer type
Go to solution
Solved by Darko_Nerivar,
That's just a warning
Compiles just fine
foo@bar:~$ gcc -o test test.ctest.c: In function ‘main’:test.c:5:9: warning: assignment from incompatible pointer type [enabled by default]foo@bar:~$ ./testElement 1: 15Element 2: 20Element 3: 25Element 4: 30Element 5: 35
and this is what you get with clang:
foo@bar:~$ clang -o test test.ctest.c:2:5: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] main(){ ^~~~test.c:5:9: warning: incompatible pointer types assigning to 'int *' from 'int (*)[5]' [-Wincompatible-pointer-types] ptr = &arr; ^ ~~~~2 warnings generated.
If you write
int *ptr = arr;
instead, than no errors or warnings
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now