From: Andres Meyer <andres.meyer@connvision.com>
To: gcc-help@gcc.gnu.org
Subject: const array warning question
Date: Mon, 25 Feb 2008 12:55:00 -0000 [thread overview]
Message-ID: <1203943284.6359.10.camel@flyingtoaster> (raw)
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;
}
reply other threads:[~2008-02-25 12:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1203943284.6359.10.camel@flyingtoaster \
--to=andres.meyer@connvision.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).