为什么预处理器在#include指令中然后在[Files]部分的Inno Setup脚本中表现不同 [英] Why preprocessor behaves differently in #include directive then in [Files] section Inno Setup script

查看:98
本文介绍了为什么预处理器在#include指令中然后在[Files]部分的Inno Setup脚本中表现不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图理解使用宏搜索和查找文件时在Inno Setup脚本中包含另一个脚本文件和源文件的语法之间的区别.

Was trying to understand the difference between a syntax that would include another script file and a source file in Inno Setup script while using macros to search and find files.

我尝试使用在Inno Setup中使用通配符查找目录的方法FindFolder :

#define FindFolder(Path) \
    Local[0] = FindFirst(Path, faDirectory), \
    Local[0] ? AddBackslash(ExtractFileDir(Path)) + FindGetFileName(Local[0]) : Path

赞:

#include "{#FindFolder('..\..\..\packages\ScriptPreRequisites*')}\DotNetDependencies.iss"

推荐答案

#中,您位于 Inno Setup预处理器.

有两种进入预处理器领域的方法.

There are two ways to enter preprocessor realm.

  • 全行语法:

  • Full line syntax:

#directive args

  • 和内联语法:

  • And inline syntax:

    {#directive args}
    

    内联语法几乎专门用于 emit指令-{#emit <expression>}.因此,有一种简写格式,省略了emit:{#<expression>}.

    The inline syntax is almost exclusively used for emit directive - {#emit <expression>}. And for this reason there's a shorthand format, with the emit omitted: {#<expression>}.

    当您要在预处理器领域之外使用预处理器表达式时,内联语法很有用.就像在普通的Inno Setup部分(或Pascal脚本代码)中一样:

    The inline syntax is useful when you want to use preprocessor expression outside of preprocessor realm. Like in normal Inno Setup sections (or in Pascal Script code):

    [Files]
    Source: "{#FindFolder("..\packages\PackagesA*")}\*.*"; DestDir: "{app}"; \
        flags: recursesubdirs  
    


    尽管在 #include预处理程序指令中,您已经在预处理器领域.在那里,{#xxx}语法无效(理论上它甚至可能具有不同的[valid]含义,但实际上大括号在预处理器中没有用).


    Though in #include preprocessor directive, you are already in the preprocessor realm. And there, the {#xxx} syntax is invalid (it might even have a different [valid] meaning theoretically, but actually curly brackets have no use in preprocessor).

    #include指令的语法为:

    #include <expression>
    

    预处理器使用类似C的表达式语法.因此,在这种情况下,您的表情是:

    The preprocessor uses C-like expression syntax. So your expression in this case is:

    FindFolder('..\..\..\packages\ScriptPreRequisites*') + '\DotNetDependencies.iss'
    

    这篇关于为什么预处理器在#include指令中然后在[Files]部分的Inno Setup脚本中表现不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆