Re: How to access the global

From: Kevin Bracey (kevin.bracey_at_tematic.com)
Date: 10/07/03


Date: Tue, 07 Oct 2003 14:59:13 +0100

In message <bltqls$cfq$1@news3.tilbu1.nb.home.nl>
          "dis" <dis@hotmail.com> wrote:

> It would be more sensible to rename one of both variables, but one
> possibility would be:
>
> int x = 10;
> int main(void)
> {
> int x = 5;
> {
> extern int x;
> x; /* the expression x will evaluate to 10 */
> }
> return 0;
> }

That totally failed to occur to me (and all the other respondents I've seen).
I'm not sure whether to complement you on your C prowess, or be worried what
sort of programmer would have such a scoping construct at their fingertips.

-- 
Kevin Bracey, Principal Software Engineer
Tematic Ltd                                   Tel: +44 (0) 1223 503464
182-190 Newmarket Road                        Fax: +44 (0) 1223 503458
Cambridge, CB5 8HE, United Kingdom            WWW: http://www.tematic.com/


Relevant Pages

  • Re: Endless loop question
    ... Kevin Bracey wrote: ... >> pretty clear that int mainsemantically acts the same ... >> as int mainbut as though there was an explicit void. ...
    (comp.lang.c)
  • Re: Endless loop question
    ... > pretty clear that int mainsemantically acts the same ... > as int mainbut as though there was an explicit void. ... Kevin Bracey, Principal Software Engineer ...
    (comp.lang.c)