The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ToutEnMasm on July 19, 2005, 05:38:29 PM

Title: a translation of #undef
Post by: ToutEnMasm on July 19, 2005, 05:38:29 PM
Hello,
I write a translator of the header files for masm and I don't find the equivalent of #undef.
#define _X86_    can be translate by  _X86_ equ
but #undef _X86_    ,I don't see how to translate.
            If somebody have an idea  ..., ToutEnMasm

Title: Re: a translation of #undef
Post by: Jeff on July 19, 2005, 08:05:16 PM
AFAIK, there is no equivalent in MASM.  i wanted to be able to do the same as well but couldnt.  its a shame we cant use PURGE.
Title: Re: a translation of #undef
Post by: MazeGen on July 19, 2005, 10:41:56 PM
That's one of the weak points of MASM - there's really nothing like #undef.

There's a trick how to redefine text macro without the need of #undefine, but it is another story.
Title: Re: a translation of #undef
Post by: Vortex on July 20, 2005, 05:28:33 AM
Quote
There's a trick how to redefine text macro without the need of #undefine, but it is another story.

Could you explain that method?
Title: Re: a translation of #undef
Post by: Jeff on July 20, 2005, 05:33:44 AM
text macros can be redefined if they were defined with the TEXTEQU directive.  ;)
Title: Re: a translation of #undef
Post by: Vortex on July 20, 2005, 09:05:44 AM
Hi Jeff,

This one works fine :


v TEXTEQU <trial>
v TEXTEQU
Title: Re: a translation of #undef
Post by: MazeGen on July 20, 2005, 01:54:27 PM
You can encounter this problem in some complex macro, when the symbolic name of the text macro is variable.
Because it seems to be too difficult to give clear sample proof of the solution, here is just what I was talking about:


SomeStr TEXTEQU <SymbolicName> ; SomeStr = "SymbolicName"
%SomeStr TEXTEQU <I Am A String> ; SymbolicName = "I Am A String"


Without the possibility of undefine the SomeStr macro, we can't simply redefine it:


SomeStr TEXTEQU <SymbolicName> ; SomeStr = "I Am A String"
%SomeStr TEXTEQU <I Am A String> ; I Am A String = "I Am A String"


The last statement, I Am A String = "I Am A String", is not valid - assembly error.

Try it:


.686
.model flat, stdcall

SomeStr TEXTEQU <SymbolicName>
%ECHO SomeStr

%SomeStr TEXTEQU <I Am A String>
%ECHO SomeStr

SomeStr TEXTEQU <SymbolicName>
%ECHO SomeStr

%SomeStr TEXTEQU <I Am A String> ; error
%ECHO SomeStr

.code
start:
end start