Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Why does 'gcc -Wall' complain about void main() ? Date: Fri, 01 Nov 2019 10:31:08 -0700 Organization: None to speak of Lines: 33 Message-ID: References: <5fXuF.717$gt2.335@fx02.iad> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="bd2070be1949be0113457798c3cfb24b"; logging-data="1127"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cMg+ms6rE+6KT/SqAHu8e" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:rNCfX6IsVEvioOTEMWHYsQZF8eE= sha1:YiisMY/wvUU0aBp8OPzYmyaFB8g= Xref: csiph.com comp.lang.c:147476 Manfred writes: > On 11/1/2019 3:45 PM, David Brown wrote: >> On 01/11/2019 15:22, DFS wrote: >>> gcc 9.1.0 on MSYS2 >>> >>> combinearrays.c:14:6: warning: return type of ‘main’ is not ‘int’ [-Wmain] >>>    14 | void main() { >>>       |      ^~~~ >>> >> >> That is because the main should be declared as either: >> >> int main(void); >> >> int main(int argc, char *argv[]); >> >> or an implementation-specific extension (*nix systems often allow a >> third "envp" pointer). > > And version 0.01 of the linux kernel had: > > void main(void) /* This really IS void, no error here. */ > { /* The startup routine assumes (well, ...) this */ The kernel is considered to be in a freestanding environment, in which the program's entry point is entirely implementation-defined. For hosted environments, main returns int (or possibly some implementation-defined type, but that's rarely if ever useful). -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */