const array warning question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
}




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux