| www.delorie.com/archives/browse.cgi | search |
| Message-ID: | <3BC35FB1.FF1958C@earthlink.net> |
| From: | Martin Ambuhl <mambuhl AT earthlink DOT net> |
| Organization: | Nocturnal Aviation |
| X-Mailer: | Mozilla 4.77 [en] (Win95; U) |
| X-Accept-Language: | en,de-CH,fr,ru,zh-CN,ja |
| MIME-Version: | 1.0 |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: compiler doesn't catch missing semicolon after struct |
| References: | <c3114d1f DOT 0110091227 DOT 17603d3b AT posting DOT google DOT com> |
| Lines: | 46 |
| Date: | Tue, 09 Oct 2001 20:33:27 GMT |
| NNTP-Posting-Host: | 64.152.170.173 |
| X-Complaints-To: | abuse AT earthlink DOT net |
| X-Trace: | newsread1.prod.itd.earthlink.net 1002659607 64.152.170.173 (Tue, 09 Oct 2001 13:33:27 PDT) |
| NNTP-Posting-Date: | Tue, 09 Oct 2001 13:33:27 PDT |
| X-Received-Date: | Tue, 09 Oct 2001 13:29:52 PDT (newsmaster1.prod.itd.earthlink.net) |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
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.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |