Re: Ahead of "main"?
- From: Barry Schwarz <schwarzb@xxxxxxxxx>
- Date: Sun, 29 Apr 2007 15:29:06 -0700
On Sun, 29 Apr 2007 21:40:00 +0100, "Malcolm McLean"
<regniztar@xxxxxxxxxxxxxx> wrote:
"mdh" <mdeh@xxxxxxxxxxx> wrote in message
news:1177877117.874830.65670@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,Some early versions of C had local functions, declared within the function
Going quite methodically through K& R ( as some of you can attest
to!), I have never seen a big diffference in declaring a function
within "main" or "ahead" of it. Now, (p119, K&R II), the discussion
states that "functions "whatever" " should be declared ahead of
main.
Is there a good reason for this?
thanks.
that called them. The idea never caught on, and it is now not possible to
declare functions within main.
It is certainly possible to declare a function within another.
Defining is prohibited but declaring is allowed. The drawback is that
the declaration has block scope and will not be visible to any other
function in the translation unit.
Old C also had no prototypes. So if you put functions in reverse order of
Not always possible if function1 and function2 call each other as part
of a recursive algorithm.
hierarchy, the compiler could do additional checking of arguments. Nowadays
we should prototype all functions, so it doesn't matter where main() is
placed, though obviously it should be either the first or the last function
for readbility.
Remove del for email
.
- Follow-Ups:
- Re: Ahead of "main"?
- From: Flash Gordon
- Re: Ahead of "main"?
- References:
- Ahead of "main"?
- From: mdh
- Re: Ahead of "main"?
- From: Malcolm McLean
- Ahead of "main"?
- Prev by Date: Re: String Comparision
- Next by Date: Re: String Comparision
- Previous by thread: Re: Ahead of "main"?
- Next by thread: Re: Ahead of "main"?
- Index(es):
Relevant Pages
|