From: Radical DOT NetSurfer AT delorie DOT com Newsgroups: comp.os.msdos.djgpp Subject: Re: compiler doesn't catch missing semicolon after struct Date: Wed, 10 Oct 2001 12:43:57 -0400 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <1hu8stke235jh08aogbbc44rojtm115j23@4ax.com> References: <3BC35FB1 DOT FF1958C AT earthlink DOT net> X-Newsreader: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: newsabuse AT supernews DOT com Lines: 70 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com GCC does some very nice Syntax Checking (more than some compilers do) and yes, GCC also has the annoying habit of SOMETIMES missing the point about a syntax error, or not telling you the correct information about an error. I use several different compilers myself. I know for a fact GCC nags about things other compilers miss; on the other hand, defining main simply: main(...argv,...argc) should indeed DEFAULT to the int main(...argv,...argc) construct, but doesn't (older compilers would have no problemwith this). Try porting msvc to any professional compiler; THEN you'll have something to really complain about and lose sleep over ;-) On Tue, 09 Oct 2001 20:33:27 GMT, Martin Ambuhl wrote: >tenbux wrote: >> >> Hi all, >> >> I was working on a fairly simple lab for a CS class, and using DJGPP >> to compile and test my programs. Here is some sample code I had >> written: >> >> #include >> >> struct bit { >> int bit; >> struct bit *next; >> } >> >> main(int argc, char *argv[]) >> { >> int x; >> FILE *in, *out; >> >> if (argc < 3) { >> puts("Usage: binprint "); >> return; >> } >> >> if ((in = fopen(argv[1], "r")) == NULL) { >> printf("Error opening input file: %s\n", argv[1]); >> return; >> } >> >> You'll notice that there is no semicolon after the struct declaration >> (as is required). But gcc didn't catch this, instead it warned me >> about main not being declared as int. > >gcc caught it. You declared main as returning a struct bit instead of >an int. It told you about, but ... > >> So when I ran the binary with no >> arguments, > >you ignored the warning and got what you deserved. > >> Is this a current bug or is it supposed >> to act that way? :) > >Don't blame the compiler for your errors.