Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: [Solved] Need some help getting to my feet Date: Thu, 26 Apr 2018 07:26:35 -0700 Organization: None to speak of Lines: 48 Message-ID: References: <0c6e134d-8f31-4ceb-815c-168df4ad65de@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="751013466cf4d83a736ec69fbb9af6e9"; logging-data="23088"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zPxNaDXts5DB+zP8SEIMA" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:uaEtag+Spd4R5pVvWTEJypksIyw= sha1:n/aWwIMVFVlYTkBLw3J9KCLaeQM= Xref: csiph.com comp.lang.c:129789 1alvinalbrecht1@gmail.com writes: > On Wednesday, April 25, 2018 at 10:24:57 AM UTC-6, Keith Thompson wrote: >> Schildt's use of void main() is inexcusable, not just because >> it's wrong but because it's a symptom of his technical sloppiness. >> He wrote a book "The Annotated ANSI C Standard" consisting of the >> 1990 ISO C standard with his annotations on facing pages. He used >> "void main(void)" as an example right next to the section of the >> standard that requires the return type to be int. > > Just above that the standard will be talking about free-standing > implementations where it will state that main is implementation > defined. You're right, and I probably should have mentioned that. For hosted implementations (in C90), main *must* be defined with a return type of int. Defining it with any other return type causes undefined behavior (which can, of course, appear to "work"). (C99 added permission for other implementation-defined forms.) For freestanding implementations, the type and name of the program's entry point are implementation-defined. That's not what Schildt was talking about, though. He used "void main(void)" in his commentary on the section of the standard that specifically talks about hosted implementations. > It is quite common to see "void main(void)", "int main(void)" > and sometimes other strange forms if the crt is written for a > specific application. > The requirement that main have form "int main()" or "int main(int > argc, char **argv)" is really only speaking to (mainly) unix and > windows (the "hosted" environment). These don't make sense in > the majority of embedded applications which is one of the main > application domains of C. It's "(mainly) unix and windows" only because those are the most common platforms for hosted implementations these days. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"