[fpc-pascal] Re: [Bulk] Re: Namespaces Support
Marcos Douglas
md at delfire.net
Mon Nov 4 16:06:13 CET 2013
On Mon, Nov 4, 2013 at 11:36 AM, Dmitry Boyarintsev
<skalogryz.lists at gmail.com> wrote:
> On Mon, Nov 4, 2013 at 9:08 AM, Marcos Douglas <md at delfire.net> wrote:
>>
>> 2- If ExtraUtils depends on StrUtils.pas from "lib". But "otherlib" is
>> not a subdirectory of lib then the "otherlib needs to be compiled
>> using a ALIAS:
>> -ALIAS=TheLib at lib\*
>
> Ah, yes, you've mentioned the necessity for two steps compilation.
> (compile a package first and then compile the program).
This is not required is optional.
> Which brings the necessity for external "tools" (similar to make files) or
> an IDE must be smart enough to handle them.
> (please note "an IDE", thus not refer erring to Lazarus specifically).
No one compiles programs using line code options. Everybody uses a IDE
or script for do it.
But I did not see what the problem because it is only a new argument
for the compiler.
> But, it might help solving the problem with object names, since a recompiled
> package will update object files. hmm.. or not.
I don't know either.
>> But, for me, doesn't any sense the otherlib does not know the lib's
>> sources.
>
> Otherlib knows about "lib"s sources - it knows that there should be
> "StrUtils" unit.
> However, it doesn't know anything about there the "StrUtils" is located, as
> well as it doesn't care what to do with other files of the project. It's
> compilers job.
I know. When as said "Otherlib do not known about Lib" I was talking
about source paths.
> In my turn, this is how I'd suggest to compile it:
>
> program\unit1.pas (uses lib/StrUtils.pas)
> program\StrUtils.pas
> program\unit2.pas (uses program/StrUtils.pas)
> lib\StrUtils.pas
> otherlib\ExtraUtils.pas (uses lib/StrUtils.pas)
> --
> fpc
> -SEARCH program/unit1.pas lib/StrUtils.pas (point unit1 to use
> lib/StrUtils explicitly)
> -SEARCH otherlib/ lib/ (point "otherlib" units to use any unit from "lib"
> first, if found)
> -Fulib
> -Fuotherlib
> program.pas
>
> That's it, compile everything in one call.
If you do not change the unit names, how you can use StrUtils from
Lib, OtherLib and program in a same unit?
You need to have a identifier for each unit in your program. I can't
read the unit1 that have "uses StrUtils" and not knowing which unit
the program is refering.
> However, the problem with object name conflict (if packages are precompiled)
> doesn't allow this to happen.
> * using internal linker could help to solve this problem (in that case FPC
> could whatever it wants)
> * generating object files during the actual compilation could also help this
> problem (thus "precompile" will only prepare .ppu files with some kind of a
> code, in some kind of form). During the compilation, the code from .ppu will
> be transfered to .object files with the names changed to avoid conflicts.
Regards,
Marcos Douglas
More information about the fpc-pascal
mailing list