Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Incompatible pointer types with GCC |
| Date | 2016-12-16 11:06 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <o30ho7$4c1$1@dont-email.me> (permalink) |
| References | <o30g9b$v1l$1@dont-email.me> |
On 16/12/2016 10:41, August Karlstrom wrote:
> My question is whether this is a valid ANSI C (C89) program or not:
>
> typedef int Row[10];
>
> void P(const Row A[])
> {
> }
>
>
> int main(void)
> {
> Row A[10];
>
> P(A);
> return 0;
> }
>
> It compiles cleanly with Clang 3.5.0 and the options -pedantic -std=c89
> -Wall.
>
> GCC 4.9.2, however, is not happy:
>
> $ gcc -c -o test.o -g -pedantic -std=c89 -Wall test.c
> test.c: In function ‘main’:
> test.c:12:4: warning: passing argument 1 of ‘P’ from incompatible
> pointer type
> P(A);
> ^
> test.c:3:6: note: expected ‘const int (*)[10]’ but argument is of type
> ‘int (*)[10]’
> void P(const Row A[])
> ^
>
> Any clues?
I get:
c.c:16:9: warning: pointers to arrays with different qualifiers are
incompatible in ISO C [-Wpedantic]
P(A);
^
I suspect that, because of the typedef 'Row', the 'const' doesn't apply
to the bit that you think it does. Try dumping 'const' for now and add
it later when the program works.
Or remove the typedef which I think causes problems with arrays.
--
Bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Incompatible pointer types with GCC August Karlstrom <fusionfile@gmail.com> - 2016-12-16 11:41 +0100
Re: Incompatible pointer types with GCC BartC <bc@freeuk.com> - 2016-12-16 11:06 +0000
Re: Incompatible pointer types with GCC Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-16 17:07 +0000
Re: Incompatible pointer types with GCC August Karlstrom <fusionfile@gmail.com> - 2016-12-16 23:02 +0100
Re: Incompatible pointer types with GCC Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-17 00:48 +0000
Re: Incompatible pointer types with GCC martin.uecker@med.uni-goettingen.de - 2016-12-18 08:06 -0800
Re: Incompatible pointer types with GCC Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-18 20:11 +0000
Re: Incompatible pointer types with GCC supercat@casperkitty.com - 2016-12-18 14:43 -0800
Re: Incompatible pointer types with GCC Tim Rentsch <txr@alumni.caltech.edu> - 2016-12-29 13:33 -0800
csiph-web