Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!charyb!dan From: dan@kfw.COM (Dan Mick) Newsgroups: comp.lang.c Subject: Re: scope Q Message-ID: <1991Apr23.001543.25152@kfw.COM> Date: 23 Apr 91 00:15:43 GMT References: <1991Apr19.151959.6847@noose.ecn.purdue.edu> Reply-To: dan@kfw.com (Dan Mick) Organization: KFW Corporation, Newbury Park, CA Lines: 35 In article <1991Apr19.151959.6847@noose.ecn.purdue.edu> muttiah@stable.ecn.purdue.edu (Ranjan S Muttiah) writes: >/* 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; > >fn1(..) >{ >.... >} > >fn2(..) >{ >.... >} > >/* beep beep, useful life of a is over */ > >fn3() >{ > >a = 5; <- undefined variable: a >... >} Yes. Split the file in two. Why on earth would you want to do something to completely frustrate the next person that looks at your code? There's no reason to "unscope" a variable; if that's what you want, use the perfectly good mechanism of splitting the file and making the variable have file scope (i.e., not extern). I mean, there may *be* a way to do this, but you really shouldn't want to. Honest.