Why preprocessor behaves differently in #include directive then in [Files] section Inno Setup script

前端 未结 1 1464
既然无缘
既然无缘 2021-01-07 10:22

Was trying to understand the difference between a syntax that would include another script file and a source file in Inno Setup script while using macros to search and find

1条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-07 11:00

    Within # you are in the "realm" of Inno Setup preprocessor.

    There are two ways to enter preprocessor realm.

    • Full line syntax:

      #directive args
      
    • And inline syntax:

      {#directive args}
      

      The inline syntax is almost exclusively used for emit directive - {#emit }. And for this reason there's a shorthand format, with the emit omitted: {#}.

    The inline syntax is useful when you want to use preprocessor expression outside of preprocessor realm. Like in normal Inno Setup sections (or in Pascal Script code):

    [Files]
    Source: "{#FindFolder("..\packages\PackagesA*")}\*.*"; DestDir: "{app}"; \
        flags: recursesubdirs  
    

    Though in #include preprocessor directive, you are already in the preprocessor realm. And there, the {#xxx} syntax is invalid (it might even have a different [valid] meaning theoretically, but actually curly brackets have no use in preprocessor).

    The syntax of #include directive is:

    #include 
    

    The preprocessor uses C-like expression syntax. So your expression in this case is:

    FindFolder('..\..\..\packages\ScriptPreRequisites*') + '\DotNetDependencies.iss'
    

    0 讨论(0)
提交回复
热议问题