Search code examples
preprocessorenvironment-variablesinno-setuppre-compilation

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


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?


Solution

  • {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.