Article View: comp.std.c
Article #4109Re: Function-prototype scope: Why?
From: Ian Cargill
Date: Mon, 25 Sep 1995 17:22
Date: Mon, 25 Sep 1995 17:22
32 lines
1817 bytes
1817 bytes
In article <KANZE.95Sep25163038@slsvhdt.lts.sel.alcatel.de> kanze@lts.sel.alcatel.de writes:
>Does this mean that you want the following to be illegal:
>
> void f( int i ) ;
> int i ; // Illegal, since `i' from f-p still
> // in scope.
>
>(I have no particular point of view concerning f-p scope, but I do
>want the above to be legal.)
Don't worry, it is. I think you may have confused 'function prototype
scope' with 'the scope of the function declaration'. (Which in this
case is a prototype.)
The function declaration (prototype) declares 'f' as a 'function
returning void'. The declarator 'f' has file scope, just like the
'i' in the _second_ line.
The scope of the 'i' in the parameter list is 'function prototype scope',
which ends at (in the words of the standard) "the end of the function
declarator". i.e. at the closing parenthesis of the function prototype.
i.e.
void f( int i, int j ) ;
^ ^
start of scope of i(?) end of scope of i / end of func'n proto. scope
--
Ian Cargill
Posting in comp.std.c is like running at high speed down a steep hill.
It's not a matter of if I will stumble and hurt myself, but when. :-)
Technical Details
Message-ID:
<812049770snz@soliton.demon.co.uk>Path:
arc1-ca.pugleaf.net!mail2news.demon.co.uk!soliton.demon.co.ukReferences:
<43cgmb$cec@news0.rain.rg.net> <43er80$458@caip.rutgers.edu> <KANZE.95Sep25163038@slsvhdt.lts.sel.alcatel.de>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!soliton.demon.co.uk From: Ian Cargill <ian@soliton.demon.co.uk> Newsgroups: comp.std.c Subject: Re: Function-prototype scope: Why? Date: Mon, 25 Sep 95 17:22:50 GMT Organization: Soliton Software Ltd. Message-ID: <812049770snz@soliton.demon.co.uk> References: <43cgmb$cec@news0.rain.rg.net> <43er80$458@caip.rutgers.edu> <KANZE.95Sep25163038@slsvhdt.lts.sel.alcatel.de> Reply-To: ian@soliton.demon.co.uk X-NNTP-Posting-Host: soliton.demon.co.uk X-Newsreader: Simple NEWS 2.0 (ka9q DIS 1.24)