Old 27th April 2007, 15:46   #1
DrDan
Member
 
Join Date: Apr 2007
Location: London, UK
Posts: 58
Unhappy Complicated LogicLib problem

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

code:
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.

code:

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:

code:

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.
Attached Files
File Type: zip eg04_logiclibmacrofun.zip (1.0 KB, 149 views)
DrDan is offline   Reply With Quote
Old 27th April 2007, 16:07   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Use the attached version. It'll also be distributed with 2.26.
Attached Files
File Type: nsh logiclib.nsh (28.7 KB, 150 views)

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th April 2007, 16:12   #3
DrDan
Member
 
Join Date: Apr 2007
Location: London, UK
Posts: 58
Thanks!

Thanks for the prompt response. I'll give it a try :-)
DrDan is offline   Reply With Quote
Old 7th June 2007, 09:54   #4
DrDan
Member
 
Join Date: Apr 2007
Location: London, UK
Posts: 58
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.
DrDan is offline   Reply With Quote
Old 7th June 2007, 21:33   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
What's the exact error you get? Is it from LogicLib?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 8th June 2007, 02:32   #6
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
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
code:
!define __t _LogicLib_Label_${__LINE__}
with
code:
!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
demiller9 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump