News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

IsMacro

Started by jj2007, December 19, 2014, 11:29:58 AM

Previous topic - Next topic

jj2007

I thought that was simple: checking if e.g. printf is already defined or not. Any better ideas than what is posted below?

include \masm32\include\masm32rt.inc

IsMacro macro NewMac
  echo
  echo testing NewMac
  ifndef NewMac
% echo @CatStr(<## Line >, %@Line, <: NewMac not yet defined ##>)
  else
% echo @CatStr(<## Line >, %@Line, <: NewMac ALREADY DEFINED - Masm32 macro? ##>)
  endif
  tmp$ CATSTR <NewMac>, <(0)>
  is=0
  % FORC c$, tmp$
ifidn <c$>, <(>
is=2
endif
  ENDM
  if is
% echo @CatStr(<## Line >, %@Line, <: NewMac not yet defined ##>)
  else
% echo @CatStr(<## Line >, %@Line, <: NewMac ALREADY DEFINED - Masm32 macro? ##>)
  endif
ENDM

.code

start:
IsMacro printf
IsMacro Printf
IsMacro print
IsMacro Print
exit

end start


Output:
testing printf
## Line 28: printf ALREADY DEFINED - Masm32 macro? ##
## Line 28: printf ALREADY DEFINED - Masm32 macro? ##

testing Printf
## Line 29: Printf not yet defined ##
## Line 29: Printf not yet defined ##

testing print
## Line 30: print ALREADY DEFINED - Masm32 macro? ##
## Line 30: print not yet defined ##

testing Print
## Line 31: Print not yet defined ##
## Line 31: Print not yet defined ##