Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!wuarchive!sdd.hp.com!samsung!olivea!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!ox-prg!msc7.comlab!imc From: imc@prg.ox.ac.uk (Ian Collier) Newsgroups: comp.lang.c Subject: Re: scope Q Message-ID: <720.imc@uk.ac.ox.prg> Date: 20 Apr 91 10:38:47 GMT References: <1991Apr19.151959.6847@noose.ecn.purdue.edu> Sender: news@prg.ox.ac.uk Reply-To: imc@prg.ox.ac.uk (Ian Collier) Organization: Oxford University Computing Laboratory, UK Lines: 25 In article <1991Apr19.151959.6847@noose.ecn.purdue.edu>, muttiah@stable.ecn.purdue.edu (Ranjan S Muttiah) wrote: >/* Is there some way I can control the scope of a variable within >a file ? Something similar to #undef when using #define */ >int a,b; ... >/* beep beep, useful life of a is over */ ... >a = 5; <- undefined variable: a How about: #define a Undefined_a ? The compiler will complain when you try to use the variable Undefined_a in fn3(). Of course you'll have to #undef it again if you want to use a later on, or if you want a local variable named a (probably bad programming practice). Or perhaps it's better to call your local variable Undefined_a? :-) Not the best idea in the world, but it probably works :-) Ian Collier Ian.Collier@prg.ox.ac.uk | imc@ecs.ox.ac.uk