wrote:
>
.... snip ...
>
> Here's a perfectly conforming C99 program
>
> #include <stdio.h>
> int foo(void *);
> int main(void) {
> const char * const p = "hello world";
> foo(p);
> return 0;
> }
> int foo(void *p) { return puts(p); }
And here is one with one less line, no requirements for exact line
equivalence, and much more understandable, especially to the
neophyte.
#include <stdio.h>
int foo(void *p) { return puts(p); }
int main(void) {
char *p = "hello world";
foo(p);
return 0;
}
I also added blank lines to separate code segments. I didn't
install 'static' qualifiers.
I thought I had eliminated all possible warning, but I got:
junk.c:6: warning: initialization discards qualifiers from pointer
target type
and I am confused. Why? gcc is run through an alias for cc:
alias cc=gcc -W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal
-gstabs+ -ftrapv -O1
(I suspect the -Wwrite-strings param).
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
--
Posted via a free Usenet account from
http://www.teranews.com