【问题标题】:NSIS Function with more than 1 parameters具有超过 1 个参数的 NSIS 函数
【发布时间】:2012-05-14 00:17:13
【问题描述】:

一个 NSIS 函数可以有多个参数吗?

为什么这段代码不能编译?如果一个函数的参数不能超过 1 个,我还有哪些其他选项(不考虑使用宏)?

编译错误:

函数需要 1 个参数,得到 4 个。用法:函数 function_name

Outfile "test.exe"
Caption ""
Name ""

# Compile Error Here: "Function expects 1 parameters, got 4. Usage: Function function_name"
Function MyFunction p1 p2 p3
    DetailPrint "$p1, $p2, $p3"
FunctionEnd

Section
    DetailPrint "Hello World"
SectionEnd

【问题讨论】:

    标签: nsis


    【解决方案1】:

    你必须在寄存器和/或stack上传递参数:

    Function onstack
    pop $0
    detailprint $0
    FunctionEnd
    
    Function reg0
    detailprint $0
    FunctionEnd
    
    Section
    push "Hello"
    call onstack
    strcpy $0 "World"
    call reg0
    SectionEnd
    

    【讨论】:

    • 当你调用一个函数时,你可以内联传递它的参数。它使用堆栈还是注册表?
    • @Ring 不,您不能内联传递它们。您可以在使用 dll::export 插件语法时执行此操作,但编译器会将其转换为推送...
    • 我正在查看其中一个函数的来源:对于大多数库,它们包含一个 !macro 定义,允许用户提供内联参数。在 (explode nsis.sourceforge.net/Explode) 的情况下,参数被推送并且返回被弹出。
    猜你喜欢
    • 2018-02-25
    • 1970-01-01
    • 1970-01-01
    • 2020-10-01
    • 1970-01-01
    • 2015-10-15
    • 2015-03-08
    相关资源
    最近更新 更多