scope Q

Ian Collier imc at prg.ox.ac.uk
Sat Apr 20 20:38:47 AEST 1991


In article <1991Apr19.151959.6847 at noose.ecn.purdue.edu>,
  muttiah at 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 at prg.ox.ac.uk | imc at ecs.ox.ac.uk



More information about the Comp.lang.c mailing list