macros.asm<>ucmacros.asm: constants name conflict

Started by qWord, April 12, 2010, 01:49:30 PM

Previous topic - Next topic

qWord

here an example throwing errors:
include masm32rt.inc
include \masm32\macros\ucmacros.asm
...
mov hInstance,rv(GetModuleHandle,0) ; a call to rv(), fn,rvc() and fnc macros are also affected
...
invoke lstrcmpiW,uni$("bla bla"),0  ; error in uni$()

This problem is cause by rv-macro, which creates an EQU named 'arg' - inside uni$()-macro (and WSTR) you will find the following line:
% FORC arg, <nustr>
here arg gets expand to 'invoke GetModuleHandleA,0', which cause the error.
My suggestion is to make the constants in rv,rvc,fn and fnc unique (or local)

regards, qWord
FPU in a trice: SmplMath
It's that simple!

hutch--

Thanks, I will have to have a look at that. probably tweak the unicode macros so they don't conflict with they ANSI ones.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

qWord

#2
hi,
I've written an extended version of WSTR which adds some features:
- quotes in quotes e.g. " ' " or ' " '
- numeric values: ... 10,13 ...
- maximal line length is something around 200
maybe it is an replacement for current version...

regards, qWord

WSTR macro lbl,args:VARARG
IFNDEF wsz_lbl_cntr
wsz_lbl_cntr = 0
ENDIF
IFB <&lbl>
wsz_lbl TEXTEQU <anonym_WSTR_>,%wsz_lbl_cntr
wsz_lbl_cntr = wsz_lbl_cntr + 1
ELSE
wsz_lbl TEXTEQU <&lbl>
ENDIF
wsz_line = 1
wsz_line_1 TEXTEQU <>
wsz_line_size = 0
wsz_size = 0
wsz_flg = 0
wsz_iarg = 1

% FOR _arg,<&args>
wsz_flg = 0
FORC char,<&_arg>
IF wsz_flg NE 0
wsz_pos INSTR 1,<"'>,<&char>
IF wsz_pos EQ wsz_flg
EXITM
ELSE
@CatStr(<wsz_line_>,%wsz_line) TEXTEQU @CatStr(%@CatStr(<wsz_line_>,%wsz_line)),<,>,wsz_quote,<&char>,wsz_quote
IF wsz_line_size GE 160
wsz_line = wsz_line + 1
wsz_line_size = 0
@CatStr(<wsz_line_>,%wsz_line) TEXTEQU <>
ELSE
wsz_line_size = wsz_line_size + 4
ENDIF
wsz_size = wsz_size + 1
ENDIF
ELSE
wsz_flg INSTR 1,<"'0123456789>,<&char>
IF wsz_flg NE 1 AND wsz_flg NE 2
EXITM
ENDIF
wsz_quote TEXTEQU <&char>
wsz_arg_size SIZESTR <&_arg>
wsz_char SUBSTR <&_arg>,wsz_arg_size,1
IFDIF wsz_char,wsz_quote
wsz_flg=0
EXITM
ENDIF
ENDIF
ENDM
IFE wsz_flg
EXITM
ELSEIF wsz_flg GT 2
@CatStr(<wsz_line_>,%wsz_line) TEXTEQU @CatStr(%@CatStr(<wsz_line_>,%wsz_line)),<,>,<&_arg>
IF wsz_line_size GE 160
wsz_line = wsz_line + 1
wsz_line_size = 0
@CatStr(<wsz_line_>,%wsz_line) TEXTEQU <>
ELSE
wsz_line_size = wsz_line_size + @SizeStr(<&_arg>)
ENDIF
wsz_size = wsz_size + 1
ENDIF
wsz_iarg = wsz_iarg + 1
ENDM
IFE wsz_flg
% .err <invalid string specifier : argument : @CatStr(%wsz_iarg)>
EXITM
ELSEIFE wsz_line_size
wsz_line = wsz_line - 1
ENDIF

align 2
IF wsz_line EQ 1
wsz_lbl WORD @SubStr(%wsz_line_1,2),0
ELSE
IFNB <&lbl>
% wsz_tmpS_&wsz_lbl struct
wsz_lbl WORD wsz_size+1 dup (?)
% wsz_tmpS_&wsz_lbl ends
% &wsz_lbl LABEL wsz_tmpS_&wsz_lbl
ELSE
wsz_lbl LABEL WORD
ENDIF
wsz_cntr = 1
REPEAT wsz_line
WORD @SubStr(%@CatStr(<wsz_line_>,%wsz_cntr),2)
wsz_cntr = wsz_cntr + 1
ENDM
WORD 0
ENDIF
endm

example:
WSTR text   ,'"double quotes"',10,13,"'singel quotes'",10,13\
            ,'%&/?,.-$~"',10,13\
            ,"long ' long ' long ' long ' long ' long ' long ' "\
            ,"long ' long ' long ' long ' long ' long ' long ' "
WSTR _title, 'some title..."TEST"' 
...
invoke MessageBoxW,0,OFFSEt text,OFFSET _title,0



FPU in a trice: SmplMath
It's that simple!