Skip to content
⌘ NSIS Forum Archive

Delayed expansion of __FILE__ and __LINE__

2 posts

todd_mm#

Delayed expansion of __FILE__ and __LINE__

Is it possible to delay the expansion of __FILE__ and __LINE__ such that I could pass the caller's context file/line to a macro?


!macro _Detail __FUNCTION __FILE __LINE msg
DetailPrint "${__FUNCTION}() [${__FILE}:${__LINE}] ${msg}"
!macroend
!define Detail `!insertmacro _Detail __FUNCTION__ __FILE__ __LINE__`

;; ...
;; In some other file...

${Detail} "Message...."
I'd like for the detail message to use the file/line number where ${Detail} was actually expanded/"invoked". Is this possible, somehow, without my having to "${__FUNCTION__}" ... everywhere I use ${Detail}?
Anders#
You have to use the dollar hack with NSIS 2 or Unicode escape in NSIS 3
!macro _Detail __FUNCTION __FILE __LINE msg

DetailPrint "${__FUNCTION}() [${__FILE}:${__LINE}] ${msg}"

!macroend


!define DOLLAR "$"
!define Detail `!insertmacro _Detail "${U+24}{__FUNCTION__}" "${U+24}{__FILE__}" ${DOLLAR}{__LINE__}`
Function/Section can probably be expanded inside the macro.