Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Function and variable declarations

Reply
Thread Tools

Function and variable declarations

 
 
Keith Thompson
Guest
Posts: n/a
 
      11-30-2005
"pemo" <(E-Mail Removed)> writes:
> "Flash Gordon" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)-gordon.me.uk...
>> pemo wrote:
>>
>> <snip>
>>
>>> I'm still a bit 'old school' I'm afraid, and typically declare my
>>> variables at the top of a function - no matter where they're used in that
>>> function.
>>>
>>> Many years ago, I would have loved having some mechanism that allowed me
>>> to declare them 'nearer' to where they were used - but, then, C wouldn't
>>> allow that. Nowadays, [being an 'old dog' that can't learn 'new tricks']
>>> I stick

>>
>> Must be very old school, since it is allowed by C89.

>
> Um, let's see - can't remember exactly when I started, but it was around
> 1980 [and I used to be quite good at it then I believe]


Ok, that's pre-ANSI, but I think it's post-K&R1.

As far as I know, the following was legal even back then:

main()
{
int function_scope_var;
{
int block_scope_var;
}
{
int another_block_scope_var;
}
}

Were you using a compiler that didn't allow it?

(Of course mixing declarations and statements wasn't allowed until C99.)

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable argument function as a parameter of a variable argument function AikidoGuy C Programming 11 11-21-2011 10:43 PM
Variable declarations TCB ASP .Net 3 03-21-2006 07:18 PM
member variable declaration and forward declarations John Ratliff C++ 2 08-26-2005 07:50 PM
Visual Studio forgets about variable declarations Nick Stansbury ASP .Net 2 04-11-2005 10:21 AM
function declarations, global/within a function? Douglas C Programming 2 07-05-2004 08:54 PM



Advertisments