Path: utzoo!attcan!uunet!fernwood!apple!sun-barr!cs.utexas.edu!usc!brutus.cs.uiuc.edu!psuvax1!psuvm!psuecl!bpm From: bpm@psuecl.bitnet (Brian Moquin) Newsgroups: comp.lang.c Subject: C's Limited Macro Capabilities Message-ID: <69517@psuecl.bitnet> Date: 3 Dec 89 03:58:39 GMT Organization: Engineering Computer Lab, Pennsylvania State University Lines: 13 A student in my C class asked me an interesting question: can you have conditional compilation directives embedded within '#define' macros? The answer is no. The student pointed out that this then severely limits the macro capabilities of C. He said that in assembler (MASM, I'm sure), he can write macros which contain arguments that determine how the macros get expanded. I had trouble coming up with a good analogous example in C, but here's one to think about: #define cast(flag,x) #if flag=='I' \ ((int)(x)) \ #elif flag=='F' \ ((float)(x)) \ #endif This is not legal C, but if it were I think it would enhance the power of macro expansions significantly. Thoughts?