How to set ISPP defines based on default Inno Setup variables?
Asked Answered
P

3

2

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?

Papilloma answered 18/2, 2011 at 16:36 Comment(4)
Why do you want to make a variable definition to a constant, can't you just write the constant to the place of the defined variable?Balalaika
@Balalaika Hi again chapín! =) I always use oversimplified examples in my SO questions. The real code is much more useful than the one you see. I assure you that.Papilloma
Hi again! I don't mind the code is not useful, in fact I appreciate the fact you don't show all the code just to ask a question ... I mean I don't see a useful use to a define like that... If you elaborate a bit more on what you want to get...Balalaika
This depends on what you intend to use that define for. Are you interested in the path of the common app data folder on the machine where you compile the installer or on the machine where the compiled installer is run? See my answer on how to handle either case.Accouterment
A
3

{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:

#define CommonAppData GetEnv("COMMONAPPDATA")

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:

#define CommonAppData "{commonappdata}"

Hope this helps.

Accouterment answered 4/3, 2011 at 13:15 Comment(0)
B
2

#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:

Inno Setup Preprocessor (ISPP) is an add-on for Jordan Russell's Inno Setup compiler. More technically speaking, it is an additional layer between GUI (your Inno Setup script) and the compiler, which before passing the text intercepts and modifies it in a way it is told by using special directives in the script text.

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.

Balalaika answered 21/2, 2011 at 16:56 Comment(0)
H
1

You'll probably need to escape the brace. Something like:

#define CommonAppData {{commonappdata}
Handed answered 18/2, 2011 at 17:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.