Recent

Author Topic: Lazarus wrongly pick up unit file  (Read 3417 times)

bpranoto

  • Full Member
  • ***
  • Posts: 134
Re: Lazarus wrongly pick up unit file
« Reply #15 on: August 31, 2019, 05:31:38 pm »
... anyway I have a more serious look later, should be possible.

Thank you very much Thaddy..

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus wrongly pick up unit file
« Reply #16 on: August 31, 2019, 05:39:17 pm »
Code: [Select]
[quote ]
However, it still compiles the wrong unit file in the app directory
- and wants to archive it by putting all his "the_modul" into sub-directories (that means NONE is in path by default)

Again, no matter what you do: Within the collection of all and any path that you compile any unit from => Each unit can only exists once.

So the other "the_modul" must be in a sub directory too. And at any time, only one of the 2 subdirectories is allowed to be included.


As Thaddy says, using directories that way, to cope with alternate units of the same name: Always a problem.

All my approach attempts to do, is to keep the problem as small as possible.


What you really have is 2 projects. (in one projectgroup)
The shared code should be in a package.
But that is a lot more work to set up.

Or if the_modul is code only (and no lfm). Or differs in code only... Then you only need one file (and only one project, and no package). And a big IFDEF inside it.
« Last Edit: August 31, 2019, 05:43:38 pm by Martin_fr »

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: Lazarus wrongly pick up unit file
« Reply #17 on: August 31, 2019, 05:39:56 pm »
in the simplest case, which almost always work,
Open up the lpR file and then specify the unit in the uses clause with in.

So: e.g:
Code: Pascal  [Select][+][-]
  1. program useless;
  2.   uses my_special in './extra/special.pas',
  3.   sysutils, classes, lclintf, whatever;
  4.  
Here's the whatever unit...., it is free...
Code: Pascal  [Select][+][-]
  1. unit whatever;
  2. interface
  3. implementation
  4. end.
That's being sarcastic on purpose, with good intention. (take it with a light heart and attack on content)
« Last Edit: August 31, 2019, 05:43:19 pm by Thaddy »
Specialize a type, not a var.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Lazarus wrongly pick up unit file
« Reply #18 on: September 01, 2019, 11:47:32 am »
However, maintaining several project will be easier if the ide doesn't search the paths if the unit directory specified explicitly.
The IDE has nothing to do with it. It's the compiler and it is by design: you only provide directories to the compiler, not filenames. The compiler itself searches the files and there the rule is first come first serve (and the unit output directory as well as the directroy of the main program file are always first).

You can not use the in on a unit level. anyway I have a more serious look later, should be possible. (even by deleting the *.lpi and let it regenerate by opening the *.lpr, note I and R: I means shit a not fully architected meta-information storage, whereas (lp) R is a program.)
Contrary to your believe in can indeed be used on the unit level as well. However if relative paths are used the compiler currently uses its current working directory to resolve these. I'll have to check whether this is by intention, cause for units it would definitely be better if the directory of the currently compiled unit is used as basepath...

bpranoto

  • Full Member
  • ***
  • Posts: 134
Re: Lazarus wrongly pick up unit file
« Reply #19 on: September 01, 2019, 11:59:41 am »
The IDE has nothing to do with it. It's the compiler and it is by design: you only provide directories to the compiler, not filenames. The compiler itself searches the files and there the rule is first come first serve (and the unit output directory as well as the directroy of the main program file are always first).

Thank you for the explanation.

On the positive side it forces us to give good and clear unit file names which will eliminate ambiguities.

 

TinyPortal © 2005-2018