Subject: Re: how to correct for compiler errors
To: None <netbsd-help@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: netbsd-help
Date: 04/11/2001 20:42:04
In article <200104110450.NAA16904@ibr1.irm.nara.kindai.ac.jp>,
Henry Nelson <henry@irm.nara.kindai.ac.jp> wrote:
>There are a bunch of tiny but essential utilities I'm building for the
>first time on NetBSD. (The final stage of escape from Solaris. Yippee!)
>
>I keep getting the same kinds of compiler warnings (both NetBSD 1.4.3
>and 1.5), but not being a programmer I don't know how to correct for them.
>Two very frequent ones are "assignment makes pointer from integer without
>a cast" and "`xxx_yyy' was declared implicitly `extern' and later `static'".
>Is there someone who could advise me on corrections using the examples
>below so that "egcs-1.1.1" doesn't issue warnings.
>
>1) The warning:
>windows.c: In function `fopentmpfile':
>windows.c:151: warning: assignment makes pointer from integer without a cast
>1) The "offending" code:
> if( fp = fdopen(fd,FOPEN_RWB) ){
> ==>> tmpfiles[tmpfilex++] = stralloc(path);
> LV("fopentmpfile(%s) %x/%d",path,fp,fileno(fp));
> }else LE("cannot fdopen(%d) %s",fd,path);
>
stralloc() needs to be declared appropriately before it is used.
>2) The warning:
>TLX.c:555: warning: `fa_xp' was declared implicitly `extern' and later `static'
>TLX.c:488: warning: previous declaration of `fa_xp'
>2) The "offending" code:
> ==>> static fa_xp(ofsp,regexp,class)
>(the previous declaration was: "return fa_xp(fa_root,regexp,class);"
>
>(Actually, in the second case I've just been changing all those "static"s
> to "extern". It works as far as shutting the compiler up, but is it messing
> up the code? Should I be going the other direction?)
you should be going the other direction; you need to declare the function
before you use it. and you need to declare it consistently. Older versions
of gcc allowed:
static void foo(void);
followed by:
void foo(void) {
}
christos