Path: csiph.com!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: Fri, 27 Apr 2018 14:51:40 -0700 Organization: None to speak of Lines: 46 Message-ID: References: <0db1659a-6249-47d0-8fab-baf080d32f76@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="cc0e2a6c7d0567601a378dba59302632"; logging-data="10663"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+59Ux9ZzEqwZSLufZbK4pr" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:ihWJ9tdzTzPpwd2qwzyr4ktwySk= sha1:9eLqrOwkWxGigYVRXw5fEJ/A5Jo= Xref: csiph.com comp.lang.c:129877 bartc writes: > On 27/04/2018 21:47, Keith Thompson wrote: [...] >> The "main()" line is an old-style non-prototype (`main()` should be >> `main(void)`) *and* it relies on the obsolete "implicit int" rule >> (it should be preceded with `int`): >> >> int main(void) >> >> I don't want to imply that this is a huge deal. [...] > But one of the two more important things to take away from this is that > the language allows you to leave out the type of variable or function, > and it will assume it is int. If it isn't, then tough. Incorrect. C99 dropped the "implicit int" rule. This: main() { } is a syntax error in C99 and later. Most compilers still permit it, either in some pre-C99 or non-conforming mode or as an extension. > Although some compilers will warn about this. Yes, if you bother to learn how to invoke them correctly. > The other thing is the use of the () parameter list in a function > declaration, which the language also allows, but compilers are less > likely to warn about it. Here it won't assume anything, but silently > allow any arguments at all to the function, even if they are contradictory: > > extern void fn(); > f(); > f("one","two","three"); > > At most one of these will have the correct arguments, so at least one > call must be wrong, but the compiler will say nothing unless you > explicitly tell it to report an error. So don't do that. -- 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"