Skip to content
⌘ NSIS Forum Archive

Is there a way to get a warning when a constant is undefined?

5 posts

tham123#

Is there a way to get a warning when a constant is undefined?

Consider the following code:

VIProductVersion "1.1.1.${PATCH_VER}" 
If PATCH_VER was not set earlier by a mistake, the version will turn out to be 1.1.1.${PATCH_VER}.

Is there any way to get an error/warning message in a situation like this?

Use case: We have a lot of installers being built and NSIS files change regularly, and a mistake like this will not get noticed unless manually checked.
Anders#
VIProductVersion "1.1.1.${PATCH_VER}"
VIAddVersionKey "ProductName" "Test Application"
does not compile in NSIS v3 if PATCH_VER is not defined to be a valid number.
tham123#
Originally Posted by Anders View Post
does not compile in NSIS v3 if PATCH_VER is not defined to be a valid number.
Sorry, that was a bad example. I meant something like this:

VIAddVersionKey "FileDescription" "My ${APP_NAME} Installer" 
Is there a way I can get a warning/error if APP_NAME is not defined here?
Anders#
You can use a little hack like this:

!macro VIAddVersionKey name data
!define /redef TEMPCHECK_VIAddVersionKey ""
!searchparse /noerrors "${data}" "${U+24}" TEMPCHECK_VIAddVersionKey
VIAddVersionKey "${name}" "${data}"
!if "${TEMPCHECK_VIAddVersionKey}" != ""
!error "Bad VIAddVersionKey data: ${data}"
!endif
!undef TEMPCHECK_VIAddVersionKey
!macroend
!define PATCH_VER 2
!insertmacro VIAddVersionKey "ProductName 1" "Test Application PATCH_VER"
!insertmacro VIAddVersionKey "ProductName 2" "Test Application ${PATCH_VER}"
!insertmacro VIAddVersionKey "ProductName 3" "Test Application ${PATCH_VER_DOESNOTEXIST}" 
Will not work if your string is supposed to contain a $ but then you could change the search to ${ probably...