View Issue Details

IDProjectCategoryView StatusLast Update
0038364FPCDocumentationpublic2021-03-07 19:14
ReporterMarco van de Voort Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Fixed in Version3.3.1 
Summary0038364: $unitpath documentation
DescriptionThe unitpath directory doesn't document what is the root of relative paths in the $unitpath directive, even
though it recommends relative paths

https://www.freepascal.org/docs-html/prog/progsu120.html

Logical options are (1) current directory, (2) directory where the unit is that is being compiled.
TagsNo tags attached.
Fixed in Revision1815
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Marco van de Voort

2021-02-11 10:37

manager   ~0128883

Same thing for paths in source like

uses x in '/a/b/c/y.pas';

Michael Van Canneyt

2021-02-11 10:45

administrator   ~0128884

Do you know what the root is ?

Marco van de Voort

2021-02-11 11:44

manager   ~0128887

No, I haven't checked. I just noticed that both features come up a lot in unexpected "unit not found" problems. I don't know what Delphi does ( USES..IN construct) and what the intention behind these were.

The problem with using the current directory rather than the source file as root is that when a unit with such construct gets implicitly compiled, the root is different. In that case these constructs should probably be limited to library or program modules.

Marco van de Voort

2021-02-11 11:54

manager   ~0128888

It seems $unitpath is relative to module source:

(scandir.pp:1540 and thereabouts)

            if (current_module.path<>'') and
               not path_absolute(unitpath) then
             unitpath:=current_module.path+source_info.DirSep+unitpath;

The IN case I can't read as easily from the source, and has Delphi compatibility concerns (which I also don;'t know)

Michael Van Canneyt

2021-03-07 19:14

administrator   ~0129490

I tested. The
a in 'sub/a.pp'
uses the current working directory of the compiler.

Documented, and documented that $UNITPATH uses the unit source path as starting point.

adding {$UNITPATH sub} to your program will therefor make sure it can be compiled from anywhere if you use 'a in xyz '

Issue History

Date Modified Username Field Change
2021-01-16 21:25 Marco van de Voort New Issue
2021-01-16 21:25 Marco van de Voort Status new => assigned
2021-01-16 21:25 Marco van de Voort Assigned To => Michael Van Canneyt
2021-01-19 11:21 Marco van de Voort Description Updated View Revisions
2021-01-19 11:21 Marco van de Voort FPCTarget => -
2021-02-11 10:37 Marco van de Voort Note Added: 0128883
2021-02-11 10:45 Michael Van Canneyt Note Added: 0128884
2021-02-11 11:44 Marco van de Voort Note Added: 0128887
2021-02-11 11:54 Marco van de Voort Note Added: 0128888
2021-03-07 19:14 Michael Van Canneyt Status assigned => resolved
2021-03-07 19:14 Michael Van Canneyt Resolution open => fixed
2021-03-07 19:14 Michael Van Canneyt Fixed in Version => 3.3.1
2021-03-07 19:14 Michael Van Canneyt Fixed in Revision => 1815
2021-03-07 19:14 Michael Van Canneyt FPCTarget - => 3.2.2
2021-03-07 19:14 Michael Van Canneyt Note Added: 0129490