<div dir="ltr">Hmm, let me extend your example:<div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">/project/unit1.pas</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">/project/StrUtils.pas</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">/lib/StrUtils.pas</span><br style="font-family:arial,sans-serif;font-size:13px"></div><div><span style="font-family:arial,sans-serif;font-size:13px">/lib/ExtraUtils.pas</span></div>
<div><br></div><div><font face="arial, sans-serif">---code---</font></div><div><font face="arial, sans-serif">unit ExtraUtils;</font></div><div><br></div><div><font face="arial, sans-serif">uses StrUtils; // assumed library StrUtils, not project</font></div>
<div><font face="arial, sans-serif">===code===</font></div><div><font face="arial, sans-serif">However, since StrUtils is present in project directory, it will be used instead, causing compilation errors.</font></div><div>
<font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">compiling with</font></div><div><span style="font-family:arial,sans-serif;font-size:13px">fpc -ALIAS /lib/* TheLib</span><font face="arial, sans-serif"><br>
</font></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">won't help, unless you change "ExtraUtils.pas" to use TheLib.StrUtils</span></div>
<div><br></div><div><font face="arial, sans-serif">Your thoughts?</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">My proposal looks like this:</font></div><div><font face="arial, sans-serif">-SEARCH</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">fpc -SEARCH/program/unit1.pas@/lib/ </font></div><div><br></div><div><font face="arial, sans-serif">Causing fpc to look for units at "Libs" first when compiling "/program/unit1.pas"</font></div>
<div><font face="arial, sans-serif">No changes in any source code necessary.</font></div><div>With the swicth present </div><div>---code---</div><div>unit unit1</div><div><br></div><div>uses StrUtils; // strutils from lib</div>
<div>===code===</div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">thanks,</font></div><div><font face="arial, sans-serif">Dmitry</font></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif"><br></font></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Nov 2, 2013 at 6:55 AM, Marcos Douglas <span dir="ltr"><<a href="mailto:md@delfire.net" target="_blank">md@delfire.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Nov 1, 2013 at 11:54 PM, Dmitry Boyarintsev<br>
<<a href="mailto:skalogryz.lists@gmail.com">skalogryz.lists@gmail.com</a>> wrote:<br>
> Technical problem:<br>
> * a unit name collision of two independent library code. Either library are<br>
> using unit with the same name. The code in the conflicting units is<br>
> different. Thus one library should use its own unit, the other should use<br>
> its own.<br>
> Since FPC allows to specify the search path for the whole compiled program,<br>
> the second library used, will be using a wrong unit (from the first<br>
> library), causing either compilation to fail or wrong code generated;<br>
><br>
> Can anyone think of any logical problems with this feature:<br>
> * allow any unit (or units under specified directories) to use their own<br>
> "unit-search" paths, than defined for the project. In that case if a library<br>
> has its own unit, the compiler will be using the library specific unit (by<br>
> finding it in the library specific search path).<br>
><br>
> From compiler point of view - it's only a matter of where to find the source<br>
> code for the unit and how to name the resulting objects and object file.<br>
> (names must not conflict, in case some units of a compiler project match);<br>
> Linker, shouldn't have any issues as long as objects files were created<br>
> properly;<br>
> Debugging information - no problems here, since the source file name is<br>
> specified explicitly and is typically full path;<br>
><br>
> Limitations:<br>
> * two units with the same name are not allowed to be used by any other unit<br>
> at the same time<br>
> uses unitA (from pathA), unitA (from pathB) - not allowed;<br>
> * RTTI collisions are not to be resolved by this feature;<br>
<br>
</div></div>Complex...<br>
<br>
Think this:<br>
/project/unit1.pas<br>
/project/StrUtils.pas<br>
/lib/StrUtils.pas<br>
<br>
===code===<br>
unit unit1;<br>
<br>
uses StrUtils; // local or Lib???<br>
===code===<br>
<br>
To compile the unit1.pas the compiler need to know where is<br>
StrUtils.pas and whether to use /lib/StrUtils or /project/StrUtils,<br>
right?<br>
So, if we could to set a parameter to compiler saying:<br>
fpc -ALIAS /lib/* TheLib<br>
<br>
Of course I invented the "-ALIAS" parameter.<br>
So, returning to unit1, if we want to use the "local" StrUtils unit,<br>
just use the name "StrUtils". But if we want to use the Lib's<br>
StrUtils, then:<br>
<br>
===code===<br>
unit unit1;<br>
<br>
uses TheLib.StrUtils;<br>
===code===<br>
<br>
What do you think?<br>
<br>
Best regards,<br>
Marcos Douglas<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</div></div></blockquote></div><br></div>