inno-setup - Inno Setup 中的 #emit 指令有什么意义?

标签 inno-setup directive preprocessor

以下是 #emit directive documentation 中的示例:

[Files]
#emit 'Source: "file1.ext"; DestDir: {' + MyDestDir + '}'
Source: "file2.ext"; DestDir: {#MyDestDir}
#emit GenerateVisualCppFilesEntries ; user defined function

在第一行中,我不理解 DestDir 部分。看起来那里缺少 # 符号。

我理解第二行。但为什么我们需要像第 1 行那样使用 #emit 指令呢?

最佳答案

Inno Setup preprocessor directives可以使用两种语法调用。

基本语法:

#directive params

以及内联语法:

{#directive params}

除此之外,#emit directive是默认的内联指令,当没有指定明确的指令名称时假定。


所以这三个是等价的:

#emit MyDestDir
{#emit MyDestDir}
{#MyDestDir}

虽然第一个对于 path 变量没有意义,因为它会导致无效的脚本语法 - 但它可以与包含有效脚本语法的变量一起使用:

#define FileSectionEntry 'Source: ' + MySource + '; DestDir: ' + MyDestDir
#emit FileSectionEntry

虽然其他两个内联示例可以有意义,但仅限于同一行上的其他代码,例如您问题中的代码:

Source: "file2.ext"; DestDir: {#MyDestDir}

此外,带有(字符串)常量的 #emit 基本上毫无意义,因为无需预处理器即可实现相同的效果。

这三个是等效的:

Source: "file2.ext"; DestDir: "{app}"
#emit 'Source: "file2.ext"; DestDir: "{app}"'
{#'Source: "file2.ext"; DestDir: "{app}"'}

所以回到脚本中的代码,这些(几乎)是等效的:

#emit 'Source: "file1.ext"; DestDir: {' + MyDestDir + '}'
Source: "file1.ext"; DestDir: {#MyDestDir}

唯一的问题是我认为第一行中的大括号不应该在那里。该行应该是:

#emit 'Source: "file1.ext"; DestDir: ' + MyDestDir

我已提交fix for this 。这基本上是您上一个问题中的拼写错误的另一个副本:Why is there an additional pair of curly braces on the Inno Setup Preprocessor:#emit page?

关于inno-setup - Inno Setup 中的 #emit 指令有什么意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64803379/

相关文章:

inno-setup - 选择应用程序语言并将其保存到 Inno Setup 安装程序的注册表中

jquery - 为什么在我的 AngularJS 指令中需要 <div> 包装 Jquery UI 自动完成小部件?

plugins - 如何注册 clang 预处理器插件?

installation - Inno Setup 终止正在运行的进程

winapi - 如何从 Inno Setup 中的 GetVolumeInformation 获取卷名称?

x86 - .section .text 和 .text with gas 的区别

AngularJS 代理指令

用于在注释中共享代码的 Java 预处理器

ios - 预处理器循环 '#rep #endrep' 在 Xcode 上不起作用?

inno-setup - 从代码更改组件复选框状态后,Inno Setup 更新磁盘空间