A
Andres Meyer
Hello,
I am trying to compile the very simple program below and am getting this
error:
$ gcc -Wall -ansi -o test test.c
test.c: In function âmainâ:
test.c:17: warning: passing argument 1 of âf2â from incompatible pointer
type
$ gcc --version
gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
Could someone tell me what trivial thing I am doing wrong? I am just
trying to make the int values of the array not modifiable in both
functions. I do not get this warning without the const modifiers.
Cheers,
Andres
test.c:
#include <stdio.h>
void f1(const int i[][2])
{
printf("%d\n", i[0][0]);
}
void f2(const int j[][2])
{
f1(j);
}
int main()
{
int m[2][2];
m[0][0] = 5;
f2(m);
return 0;
}
I am trying to compile the very simple program below and am getting this
error:
$ gcc -Wall -ansi -o test test.c
test.c: In function âmainâ:
test.c:17: warning: passing argument 1 of âf2â from incompatible pointer
type
$ gcc --version
gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
Could someone tell me what trivial thing I am doing wrong? I am just
trying to make the int values of the array not modifiable in both
functions. I do not get this warning without the const modifiers.
Cheers,
Andres
test.c:
#include <stdio.h>
void f1(const int i[][2])
{
printf("%d\n", i[0][0]);
}
void f2(const int j[][2])
{
f1(j);
}
int main()
{
int m[2][2];
m[0][0] = 5;
f2(m);
return 0;
}