TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JERRY COFFIN
from: ROGER SCUDDER
date: 1997-09-02 15:23:00
subject: void main() again / size

Hi JERRY,
JERRY COFFIN was observed on 31-Aug-97, writing to ROGER SCUDDER
          Something about: void main() again / size
 JC> Note that there's no real ambiguity here: a declaration using
 JC> `main()' means `main(...);', but a definition of `main()' means
 JC> `int main(void)'. However, there's rarely a reason to have a
 JC> declaration of main separate from the definition.  In theory it
 JC> could make sense if you had a function preceding main in the
 JC> source file which was going to directly call main.
 Ah... Jerry...
 I want to take it in the direction of C++ so I moved it to
 the C++ echo.
 Speaking only of decelerations for now... I want to get away from
 decelerations of main and discuss function decelerations other
 that main.   A function deceleration and a function prototype
 are the same thing, right?  I mean a prototype does not
 allocate memory.  I'm not sure just how it works, but you can
 not call a function until it had been defined, right?  So is
 a prototype just a string literal that the compiler can use
 as a guide to check against any subsequent definitions of the
 function for differences?  Is the prototype copied into some
 reference table or something?
 Going back to the original thread, The book I am reading right
 now, which may be outdated (1994) on this topic, states that an
 ANSI C compiler will evaluate a prototype (or deceleration)
 int foo() and int foo(...) as equivalent. OTOH, a C++ compiler
 will interpret int foo() as meaning int foo(void).  It states
 that the syntax int foo() is obsolete under C++.
 JC> Under C++, `main()' is illegal because C++ makes implicit return
 Thanks. I didn't make a strong connection to that point when I
 read it.  Now that you reinforced it I have it down and clear.
 JC> types illegal.  However, a definition of main as `int main()'
 JC> means exactly the same thing under C++ as it does under C.  As I
 JC> pointed out above, there's rarely if ever a need for a declaration
 JC> of main, which is where there would be a difference in meaning
 JC> between C and C++. Later, Jerry.
 Right, but I want to explore decelerations of other functions.
 I want to know if you agree with the book (FWIW - it is named
 "The Revolutionary Guide to OOP Using C++") that int foo() is
 obsolete under C++ and that a C++ compiler will not evaluate
 a deceleration of int foo() as equivalent to int foo(...) as
 is the behavior for a ANSI C compiler.
 phewwwww.... a lot of words to cover a simple detail... It's all
 based around the topic of porting C programs to C++.
 Roger Scudder
 rogers@gim.net
... Bad or missing MOUSE.COM.  Spank CAT.EXE? (Y/N)
--- Terminate 5.00/Pro 
 * TerMail/QWK * Terminate SmartNote: Remembers & recalls everything!
--- WILDMAIL!/WC v4.12 
---------------
* Origin: FIDONET * Remote Control BBS * 610-623-5273 * (1:273/420.0)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.