views:

71

answers:

2

Hello

In the C/C++ there are 2 types of macro:

 #define ABC   /* usual */

und

 #define FUNC(a)  /*function-like*/

But how can I undefine them?

Update: So there is no difference between undefing "constant-like macro" and "function-like macro" ?

+5  A: 
#undef ABC
#undef FUNC

#undef "cancels" out a previous #define. The effect is as though you never had a previous #define for a particular identifier. Do note that #defines do not respect scope, so it's best to use them only when you need to.

Also note that it doesn't matter if one macro identifier uses the "usual" syntax while another uses a "function-like" syntax. #define ABC and #define ABC(A) both define a macro named ABC. If you have both, without #undefing one of them, the latest one "overrides" the other. (Some compilers may emit a warning if this happens.)

In silico
LOL. I knew that was going to happen:-)
Job
+6  A: 
#undef ABC
#undef FUNC
Job
2 seconds apart. If this were a race you'd be a winner. ;p
wheaties
Another case of the Fastest Gun in the West problem: http://meta.stackoverflow.com/questions/9731/fastest-gun-in-the-west-problem ;-)
In silico
I voted you both up because *I can't decide*! :-)
T.E.D.