[How to] Command line text macro expansion in data section

Started by MazeGen, October 25, 2005, 06:32:56 PM

Previous topic - Next topic

MazeGen

At first, I wrote the following because I wanted to ask how to solve the problem mentioned in the topic, but I figured it out.
Here is the solution, if is anyone interested:

Let's consider the following masm source, cmdline_macro.asm:


.686
.MODEL FLAT, STDCALL

IFDEF CMDLINE_MACRO

%include CMDLINE_MACRO

.DATA
%BYTE "CMDLINE_MACRO" ; the macro doesn't expand this way!

xyz CATSTR <!">, CMDLINE_MACRO, <!"> ; we have to add the quotes first
%BYTE xyz ; now it works

ENDIF

.CODE
Start:
END Start


This source is compiled using

Quote
ml /c /Fl /DCMDLINE_MACRO=\masm32\include\user32.inc cmdline_macro.asm

It is defined text macro CMDLINE_MACRO on the command line. It expands to user32.inc file and its path.
This file is successfully included using %include CMDLINE_MACRO, but the macro can't get expanded using %BYTE "CMDLINE_MACRO" in data section. We have to add the quotes, see above.