delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/07/20/13:15:46

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: strange error
Date: Tue, 20 Jul 2004 13:07:33 -0400
Lines: 31
Message-ID: <2m51qlFj0vupU1@uni-berlin.de>
References: <2m4apdFht547U1 AT uni-berlin DOT de> <20040720073802 DOT 22465 DOT 00000145 AT mb-m11 DOT aol DOT com>
Mime-Version: 1.0
X-Trace: news.uni-berlin.de uzxb8nCJiRB/o8s3xn+4VAUUqskmBW5cK9u2u8vkLjNsqu7ZI3
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616
X-Accept-Language: en-us, en, de, fr, ru, zh, ja
In-Reply-To: <20040720073802.22465.00000145@mb-m11.aol.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Sterten wrote:

>  >Your program has at least the following errors:
>  >
>  >#include <stdio.h> is missing
>  >#include <stdlib.h> is missing
> 
> I assume, that stdio.h and/or stdlib.h are appended automatically
> (why else would the program run ?) and that including these
> again only blows the whole thing up unnecessarily.

There is no reason for the compiler to gratuitously include headers. 
You are in error.

> 
>  >main is defined without giving a return type
>  >main doesn't return a value
> 
> I don't need such a value here. Once I saw a recommendation somewhere
> to declare main as int. Don't remember, why.

Because the standards (both the old one, C89/90, and the new one, C99) 
say that main() returns an int in a hosted environment.
1) Under the old standard where 'int' is implicit, the explicit 'int' is 
not required but returning a value is.
2) Under the new standard where implicit 'int' is not supported, the 
explicit 'int' is required, but not returning a value is considered the 
same as having an explicit 'return 0;' so is not required.
Why anyone so lazy as to not specify the return type or to not 
explicitly write 'return 0;' escapes me.

- Raw text -


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