|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Preventing macro name expansionIs 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 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Nasm-users mailing list Nasm-users@... https://lists.sourceforge.net/lists/listinfo/nasm-users |
|
|
Re: Preventing macro name expansionErmin 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 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Nasm-users mailing list Nasm-users@... https://lists.sourceforge.net/lists/listinfo/nasm-users |
|
|
Re: Preventing macro name expansionFrank Kotler wrote:
> > 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... > %ifdef, for obvious reasons, do not expand macros in its argument, so "FlagVal %+ %1" probably ends up with either nonsense or something like "FlagVal%1", neither of which is what is desired here. I think a much easier way to do what the original poster wants is probably to use equates: %define NextFlagEnum 1 %macro FlagEnum 1.nolist FlagVal. %+ %1 equ NextEnum %assign NextFlagEnum NextFlagEnum+1 %endmacro Since equates are symbols, not macros, NASM will do the erroring out for duplicate definitions. -hpa ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Nasm-users mailing list Nasm-users@... https://lists.sourceforge.net/lists/listinfo/nasm-users |
| Free Forum Powered by Nabble | Forum Help |