preprocessorinno-setuppreprocessor-directive

I want to nest include files inside include files. Why cant I do that in Inno Setup?


So lets say I have a Inno Setup file (let's call it master.iss) with a files section like this:

[Files]
#include PathToIncludeFile\IncludeFile.iss

That works beautiful and fine. The content of IncludeFile.iss is effectively inserted into the master.iss file where the #include exists.

So now I want the content of the #include file to me nested in more includes. So the IncludeFile.iss looks like this:

#include C:\PathToFile\FileWithRealFilesDataForProject1.iss
#include C:\PathToFile\FileWithRealFilesDataForProject2.iss
#include C:\PathToFile\FileWithRealFilesDataForProject3.iss
#include C:\PathToFile\FileWithRealFilesDataForProject4.iss
#include C:\PathToFile\FileWithRealFilesDataForProject5.iss
#include C:\PathToFile\FileWithRealFilesDataForProject6.iss

The compiler for Inno Setup compiling Master.iss will say

(File: PathToIncludeFile\IncludeFile.iss \n Line 1: \n Column 11:)
[ISSP] Undeclaired Identifier C"

I suppose I could achieve what I want with a batch file or something, but it would be a lot more straight forward if I could just do this with nested #includes.

BTW: My current Inno Setup Compiler is 5.5.6 (u)


Solution

  • You can nest include files.


    Your problem is that in Inno Setup preprocessor the string literals must be enclosed in double-quotes (or single-quotes), like:

    #include "C:\PathToFile\FileWithRealFilesDataForProject1.iss"
    

    When you omit the quotes, the preprocessor tries to interpret the #include argument as an expression. Hence it treats the C (leading alphanumeric sequence) as an identifier.

    See these topics in Inno Setup Preprocessor documentation:


    For the same reason, your primary include, the way you have it in your post, won't compile either. You must have enclosed it in double quotes.

    For this:

    #include PathToIncludeFile\IncludeFile.iss
    

    I'm getting

    [ISPP] Undeclared identifier: "PathToIncludeFile".

    (as expected)