Archive: Complicated LogicLib problem


Complicated LogicLib problem
I spent all morning trying to work out what was causing the following compilation error:

NSIS Error: label "_LogicLib_Label_7.1.5:" already declared in section


It turns out to be the following: some of the code for the installer I am writing will be automatically generated and placed into a header file. This code is effectively just code portions that we !include in the Sections of the installer. E.g.


Section
DetailPrint "Installing Tool A..."

!include tool.a.nsh
!include tool.a.dependency.nsh

SectionEnd


The contents of the .nsh files is just the installation steps to install tool A, i.e. the files and directories for that tool, registry entries if needed etc.

Now, the situation I was in was that both the header files tool.a.nsh and tool.a.dependency.nsh contained a call to a certain macro (with different parameters each time) and in both cases that macro call was on line 7 of the .nsh file. I need to call this macro in the .nsh as it sets up some configuration data for use later in the installer.

This macro uses the LogicLib and having had a quick look at the LogicLib header file, it seems that the ${If} macros use the line numbers to generate goto labels based upon line numbers in the file that they are in. However, since the macro was called on the same line in each .nsh file, this meant that LogicLib generated the same label twice which, of course, confuses the compiler.

I have attached an example to illustrate this problem and it generates the error:


Error: label "_LogicLib_Label_1.1.5:" already declared in section
Error in macro _Else on macroline 13
Error in macro EG04_LogicLibMacroFun on macroline 3
!include: error in script: "tool.a.dependency.nsh" on line 1


How can I get around this problem? I can't add a new line to the .nsh files because they are to be generated by another program.

I would prefer to stick with using the LogicLib if possible, because it is easier to read and maintain.

Thanks in advance.

Use the attached version. It'll also be distributed with 2.26.


Thanks!
Thanks for the prompt response. I'll give it a try :-)


Problem solved until...
... I started using the Perl-compatible regular expression plug-in: http://nsis.sourceforge.net/NSISpcre_plug-in

This does indeed integrate with LogicLib, but it brings the original problem back :( :( :(

As a work-around, looks like we will have to add different numbers of blank lines to each of our header files to alleviate this problem.


What's the exact error you get? Is it from LogicLib?


The NSISpcre.nsh file contains the same (buggy) macro that used to be in LogicLib. You can correct the version you are using by changing the NSISpcre.nsh file in two places:

Replace the two lines (at 854 and 882) that read

!define __t _LogicLib_Label_${__LINE__}
with
    !define __t _LogicLib_Label_${LOGICLIB_COUNTER}
!insertmacro _IncreaseCounter
The LOGICLIB_COUNTER define and _IncreaseCounter macro will exist because they are in the new LogicLib that corrected the previous problem you had.

Don