I have the following code:
typedef float vec3_t[3]; void f(const vec3_t v[2]){ // do stuff } int main(int argc, char * argv[]){ vec3_t v[2]; v[2][1] = 1; f(v); return 0; }
which will not compile using
gcc main.c -std=gnu99 -O0 -o main
but give an error
main.c: In function 'main':' main.c:293:5: warning: passing argument 1 of 'f' from incompatible pointer type [enabled by default] f(v); ^ main.c:286:6: note: expected 'const float (*)[3]' but argument is of type 'float (*)[3]' void f(const vec3_t v[2]){ ^
If I, on the other hand, delete the const requirement in the function f. Everything works well. I can not understand what is wrong?
source share