From: Frank K. <fbk...@zy...> - 2008-10-15 02:33:19
|
Ermin Robert Alegrid wrote: > Is there a way to stop a (single line) macro name from being expanded? I'm writing macros which create other macros, whose names are built up using the %+ operator, and I want to be able to test if a macro with the same name exists or possibly redefine it. > > I've tried something similar to the following, but it's not working (a bunch of errors saying %xdefine and %ifdef expect identifiers, so I assume that means that it expanded the name passed to it before testing): > > %macro DefMac 2.nolist > %xdefine %1 %2 > %endmacro > > %define LastNum 1 > %macro FlagEnum 1.nolist > %warning Defining FlagVal. %+ %1 > %ifdef FlagVal. %+ %1 > %warning FlagVal. %+ %1 Redefined > %endif > DefMac FlagVal. %+ %1, LastNum > %assign LastNum LastNum << 1 > %endmacro > > FlagEnum A > FlagEnum B > FlagEnum C > ; ... > FlagEnum A > > ; ... there a way to stop a (single line) macro name from being expanded? I'm writing macros which create other macros, whose names are built up using the %+ operator, and I want to be able to test if a macro with the same name exists or possibly redefine it. > > I've tried something similar to the following, but it's not working (a bunch of errors saying %xdefine and %ifdef expect identifiers, so I assume that means that it expanded the name passed to it before testing): > > %macro DefMac 2.nolist > %xdefine %1 %2 > %endmacro > > %define LastNum 1 > %macro FlagEnum 1.nolist > %warning Defining FlagVal. %+ %1 > %ifdef FlagVal. %+ %1 > %warning FlagVal. %+ %1 Redefined > %endif > DefMac FlagVal. %+ %1, LastNum > %assign LastNum LastNum << 1 > %endmacro > > FlagEnum A > FlagEnum B > FlagEnum C > ; ... > FlagEnum A > > ; . > -------------------------------------------- > Robert Alegrid > #3164658 > BP 079 Physics Hi Robert, Thank you! Since we put the list on a "moderated" basis to eliminate spam, this is the first message I've been able to *approve*! Unfortunately, I don't know the answer to your question. Possibly "%ifidni" instead of "%ifdef" would get rid of the "identifier expected"??? I haven't had a chance to try this out... I'm not sure if there's a way to do what (I think) you want... Must be... Best, Frank |