Archive: Conditional Compilation !define


Conditional Compilation !define
Hi,

currently we have a software project, which calls the installer compilation after the compilation of the main product. Since we also have customer specific distributions, we use


The .nsh files are loaded in the main .nsh script at the beginning in the following order:

!include "settings_pre.nsh"
!include "settings.nsh"
!include "variables.nsh"

Originally Posted by settings.nsh !define APPNAME "App Name"
!define APPBINARYNAME "App Binary Name"
!define APPCONFIGNAME "App Config Name"
...
...
The settings.nsh looks like that, but setting the common definitions, however APPCONFIGNAME for example is also in it and should be overwritten in the later loaded settings.nsh, if it exists there.


My specific problem is the "already defined" error, if a definition was already set, but maybe changed during compiling the installer or in the settings.nsh.

Therefore the following questions arise:

1) Do the /D commands during compile time overwrite !define in the script?
2) How can I accomplish that definitions "maybe" loaded by the settings.nsh overwrite definitions in the settings_pre.nsh (you could call it "standard definition file")?

!ifdef foo
!undef foo
!endif
!define foo bar


or you could create a macro for those lines
!macro redefine a b
!ifdef ${a}
!undef ${a}
!endif
!define ${a} `${b}`
!macroend
!define redefine "!insertmacro redefine"


and call it like this
${redefine} foo "bar and a half"