Return to BSD News archive
Path: sserve!manuel!munnari.oz.au!spool.mu.edu!yale.edu!yale!gumby!wupost!sdd.hp.com!cs.utexas.edu!uunet!news.univie.ac.at!email!hp From: hp@vmars.tuwien.ac.at (Peter Holzer) Newsgroups: comp.unix.bsd Subject: Re: gcc 2.2.2 or 386BSD bug? Message-ID: <1992Jun23.194137.3165@email.tuwien.ac.at> Date: 23 Jun 92 19:41:37 GMT Article-I.D.: email.1992Jun23.194137.3165 References: <1992Jun22.164943.18294@ntuix.ntu.ac.sg> Sender: news@email.tuwien.ac.at Organization: Technical University Vienna, Dept. for Realtime Systems, AUSTRIA Lines: 66 Nntp-Posting-Host: quasi.vmars.tuwien.ac.at eoahmad@ntuix.ntu.ac.sg (Othman Ahmad) writes: [ I moved the error messages to the lines they belong to. I think it is easier to read that way.] >file test.c >#include <sys/file.h> Somewhere in sys/file.h a struct args is defined. >ocreat(p, uap, retval) Here starts a new scope. This scope lasts until the closing } of the function (see X3.159-1989 3.1.2.1). The standard is not entirely clear in this respect, but as I understand it, the opening brace of the function body does not start a new scope. > struct proc *p; > register struct args { > char *fname; > int fmode; > } *uap; >test.c: In function `ocreat': >test.c:7: warning: structure defined inside parms You are defining a struct stat here. It is uncommon, but legal to redefine a type in an inner scope level, so you get a warning. > int *retval; >{ > struct args { >test.c:10: redefinition of `struct args' Here you are defining struct args for the second time in this scope. This is not legal, so you get an error message. But even if it is legal (as I said, the standard is not entirely clear), this is surely nothing you would like to do in a program (except if you want to submit it for the next occc :-). > char *fname; > int mode; > int crtmode; > } openuap; > openuap.fname = uap->fname; > openuap.crtmode = uap->fmode; >test.c:17: structure has no member named `fmode' > openuap.mode = O_WRONLY | O_CREAT | O_TRUNC; > return (open(p, &openuap, retval)); >test.c:19: warning: passing arg 1 of `open' from incompatible pointer type >test.c:19: warning: passing arg 2 of `open' makes integer from pointer without a cast open is usually defined as int open (const char *name, int mode, ...), and you are calling it as if it were defined as int open (struct proc *, struct { char *; int; int } *, int *); No wonder GCC complains. What are you trying to achieve? >} -- | _ | Peter J. Holzer | Think of it | | |_|_) | Technical University Vienna | as evolution | | | | | Dept. for Real-Time Systems | in action! | | __/ | hp@vmars.tuwien.ac.at | Tony Rand |