Menu

#1321 Bug where macro parameter values are automatically modified

3.0 Series
open
nobody
bug (2)
5
2026-04-09
2025-08-24
nttwqz
No
!define PRODUCT_NAME "Bug_Demo"

Name "${PRODUCT_NAME}"
Caption "${PRODUCT_NAME}"
OutFile "${PRODUCT_NAME}.exe"

BrandingText " "
XPStyle on
ManifestDPIAware true
InstallColors /windows
ShowInstDetails show
SetFont "Microsoft YaHei" 9
RequestExecutionLevel user

Page instfiles

!macro macro_test id x y width height
  ; It has nothing to do with the system plugin operation stack, it's just what I actually need.
  System::Store 'S'
    StrCpy $6 "${x}" "" -1
  DetailPrint "-$0_${id}-${x}-${y}-${width}-${height}-"
  # If the first parameter of the macro is a variable and is the same as here, ${id} will be modified to the value of this variable.
    StrCpy $0 `${x}` -1   # ${id} == $0
  DetailPrint "+$0_${id}+${x}+${y}+${width}+${height}+" 
  System::Store 'L'
!macroend


Section
  StrCpy $0 "000"
  StrCpy $1 "111"
  !insertmacro "macro_test" $0 10 20 50 10
  DetailPrint "$0"
  DetailPrint "$1"
SectionEnd

Discussion

  • nttwqz

    nttwqz - 2025-08-24

    Is it possible to add slice support for variables, similar to Python, so that the following conditions no longer require defining another variable, which would be particularly convenient?

    ${If} $0[0:1] == 0
       Abort
    ${EndIf}
    
     
  • Anders

    Anders - 2026-04-09

    Macros are just simple text replacements happening early in the compilation process. You can work around this by forcing the caller to provide a temporary variable as a parameter.

     

Log in to post a comment.