Archive: Strange behaviour of !include


Strange behaviour of !include
Hello,

I noticed that if I add a custom include dir to the compiler, and include once a file that lives both in the NSIS include and the custom include, the compiler includes it twice :eek: !

Is it a bug or a feature?


I'd say it's neither! How should it know which of the two to include? It's your fault for putting it in both directories!

-Stu


Originally posted by Afrow UK
I'd say it's neither! How should it know which of the two to include? It's your fault for putting it in both directories!
Well... I don't think it is right to consider a case like "it's the user fault, never mind". This situation happened to me, and I just found that the compiler behaviour was strange

IMHO the compiler should either emit a warning, or include only the standard include.

Cheers

I see your point. But, consider that NSIS was purposfully designed to be as minimal as possible to cut down on on the overhead of the installation.

To get around this type of thing, you'll notice that most of the !includes included with NSIS put their includes in an !ifdef/!ifndef block. For example, if you have an include file a function 'foo', then the entire include file might be something like:


!ifndef foo
!define foo
...
[insert code here]
...
!endif

This way, if the file gets included more than once, it's no big deal since the compiler will ignore 2nd and subsequent calls to the same file.

If this is still a change you feel strongly about, then you should add it as a suggestion on the
NSIS SourceForge page.

Thanks, fixed.

http://sourceforge.net/tracker/index...49&atid=373085