如何根据默认的 Inno Setup 变量设置 ISPP 定义?
我试图:
#define CommonAppData {commonappdata}
但它产生:
编译器错误
[ISPP] 需要表达式,但找到左大括号 (“{”)。
如何使用 Inno Setup PreProcessor 来实现这一点?
I was trying to:
#define CommonAppData {commonappdata}
but it yields:
Compiler Error
[ISPP] Expression expected but opening brace ("{") found.
How to achieve this with Inno Setup PreProcessor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
{commonappdata}
无法在编译时扩展,即当预处理器运行时,因为它仅在运行时已知:它标识编译安装程序所在计算机上的公共应用程序数据目录运行。也许如果您能澄清您打算如何使用该定义,我们也许可以提供帮助。例如,如果您真正感兴趣的不是目标计算机上的公共应用程序数据目录,而是开发人员计算机上的公共应用程序数据目录,那么您可能可以使用此:
但是,如果您打算使用该定义来填充 Inno 属性,它们本身能够在运行时扩展常量,那么您应该使用它:
希望这会有所帮助。
{commonappdata}
cannot be expanded at compile time, i.e. when the pre-processor runs because it is only known at runtime: It identifies the common application data directory on the machine where the compiled installer is run.Maybe if you could clarify how you intend to use that define we might be able to help. If for example what you're really interested in is not the common app data directory on the target machine but the one on the developer machine, then you can probably use this:
If however you intend to use that define for populating Inno properties that are themselves capable of expanding the constant at runtime then you should use this:
Hope this helps.
#define
是一个 inno setup 预处理器指令,处于预编译阶段。它的工作方式很像 C 预处理器。通过定义预处理器变量,我们强制编译器在 ispp 定义解析后查看脚本:
也就是说,我无法在文档中找到源代码,也没有时间深入研究源代码,但我很确定 inno 设置变量在预编译期间不可用。
如果您只希望定义的变量包含字符串
{commonappdata}
,请直接在源中使用它...如果您希望定义的变量具有 commonappdata 的运行时值,则不需要对我来说这似乎是可能的,因为该值是在运行时确定的,因为它的当前值取决于目标机器(Windows 版本、语言等)。如果您三思而后行,那么尝试在预编译或编译时使用该值是没有意义的...这就是带来像
{commonappdata}
这样的 inno 设置常量的全部事实、{destdir}
等存在...您可以在编译时以标准方式表达未知但有意义的值,该值将在运行时已知并评估。#define
is a inno setup pre-processor directive, in a pre-compile phase. It works much like a C pre-processor.By defining a pre-processor variable, we force the compiler to see a script after the ispp defines are resolved:
That said, I can't find a source in documentation nor have time to digg into the source code, but I'm pretty sure inno setup variables are not available during this pre-compile time.
If you just want the defined variable to contain the string
{commonappdata}
, use it directly in your source... if you want the defined variable to have the run-time value of commonappdata, it doesn't seem possible to me, because that value is determined at runtime as its current value depends on the target machine (windows version, language, etc.).If you think it twice, it doesn't make sense to try to use that value at pre-compile or compile time... this is just the whole fact that brings inno setup constants like
{commonappdata}
,{destdir}
and the like to existence... that you can express in a standard way at compile time a unknown but meaningful value, which will be known and evaluated at runtime.您可能需要摆脱支架。像这样的东西:
You'll probably need to escape the brace. Something like: