* const array warning question
@ 2008-02-25 12:55 Andres Meyer
0 siblings, 0 replies; only message in thread
From: Andres Meyer @ 2008-02-25 12:55 UTC (permalink / raw)
To: gcc-help
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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-02-25 12:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-25 12:55 const array warning question Andres Meyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).