www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/10/10/13:04:12

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: <c3114d1f DOT 0110091227 DOT 17603d3b AT posting DOT google DOT com> <3BC35FB1 DOT FF1958C AT earthlink DOT net>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
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
<mambuhl AT earthlink DOT net> 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 <stdio.h>
>> 
>> struct bit {
>>   int bit;
>>   struct bit *next;
>> }
>> 
>> main(int argc, char *argv[])
>> {
>>   int x;
>>   FILE *in, *out;
>> 
>>   if (argc < 3) {
>>     puts("Usage: binprint <numbers> <output>");
>>     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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019