Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-10

uses in '' relative paths

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ryan Joseph

I'm trying "uses in" which I never knew existed before.

The idea is that I provide a path to TOML.pas using -Fu then use the "in" syntax to reference the units which are in a subdirectory. This makes it safe from the project importing the unit so any private units in the subdirectory don't override units from the importing project.

unit TOML;
interface
uses
  TOMLParser in '/sources',
  TOMLTypes in '/sources';

This doesn't seem to be working however. I was hoping that I could then omit an extra -Fu flag to the subdirectory "/sources" thus making it easier to include the main unit but maybe that's not how the "uses in" syntax works.

Regards,
Ryan Joseph

Reply by email

Mattias Gaertner
to Ryan Joseph
Show quoted text 13 lines
I'm trying "uses in" which I never knew existed before. The idea is that I provide a path to TOML.pas using -Fu then use the "in" syntax to reference the units which are in a subdirectory. This makes it safe from the project importing the unit so any private units in the subdirectory don't override units from the importing project. unit TOML; interface uses TOMLParser in '/sources', TOMLTypes in '/sources';

uses
TOMLParser in 'sources/TOMLParser.pas',

  TOMLTypes in 'sources/TOMLTypes.pas';

Not Delphi compatible.

This doesn't seem to be working however. I was hoping that I could then omit an extra -Fu flag to the subdirectory "/sources" thus making it easier to include the main unit but maybe that's not how the "uses in" syntax works.

Only in FPC:

{$unitpath sources}
interface
uses
  TOMLParser, TOMLTypes;

Mattias

Reply by email

Ryan Joseph
to Mattias Gaertner
Show quoted text 8 lines
On Oct 7, 2020, at 11:02 AM, Mattias Gaertner via fpc-pascal wrote: Only in FPC: {$unitpath sources} interface uses TOMLParser, TOMLTypes;

Some interesting stuff here, thanks. Almost there but for some reason Scanner.pas is not found even though it's in the same directory as TOMLParser.pas. The compiler did find TOMLParser despite /sources not being explicitly included as -Fu option.

unit TOMLParser;
interface
uses
  Classes,
  Scanner,    // error: Can't find unit Scanner used by TOMLParser
  TOMLTypes;

We get to TOMLParser like this:

unit TOML;
interface
uses
  TOMLParser in 'sources/TOMLParser.pas',

Regards,
Ryan Joseph

Reply by email

Marcos Douglas B. Santos
to Mattias Gaertner: On Wed, 7 Oct 2020 10:53:16 -0600 uses TOMLParser in 'sources/TOMLParser.pas', TOMLTypes…
PM Mattias Gaertner wrote 23 lines
On Wed, 7 Oct 2020 10:53:16 -0600 Ryan Joseph via fpc-pascal wrote: > I'm trying "uses in" which I never knew existed before. > > The idea is that I provide a path to TOML.pas using -Fu then use the > "in" syntax to reference the units which are in a subdirectory. This > makes it safe from the project importing the unit so any private > units in the subdirectory don't override units from the importing > project. > > unit TOML; > interface > uses > TOMLParser in '/sources', > TOMLTypes in '/sources'; uses TOMLParser in 'sources/TOMLParser.pas', TOMLTypes in 'sources/TOMLTypes.pas'; Not Delphi compatible.

I think this works even on Delphi 7...

best regards,
Marcos Douglas

Reply by email

Mattias Gaertner
to Marcos Douglas B. Santos

On Thu, 8 Oct 2020 09:37:06 -0300
"Marcos Douglas B. Santos via fpc-pascal"

Show quoted text 14 lines
[...] > > unit TOML; > > interface > > uses > > TOMLParser in '/sources', > > TOMLTypes in '/sources'; > > uses > TOMLParser in 'sources/TOMLParser.pas', > TOMLTypes in 'sources/TOMLTypes.pas'; > > Not Delphi compatible. I think this works even on Delphi 7...

Delphi allows it only in program, not in unit.

Mattis

Reply by email

Ryan Joseph
to Ryan Joseph: Some interesting stuff here, thanks. Almost there but for some reason Scanner.pas is not…
Show quoted text 11 lines
On Oct 7, 2020, at 11:15 AM, Ryan Joseph wrote: Some interesting stuff here, thanks. Almost there but for some reason Scanner.pas is not found even though it's in the same directory as TOMLParser.pas. The compiler did find TOMLParser despite /sources not being explicitly included as -Fu option. unit TOMLParser; interface uses Classes, Scanner, // error: Can't find unit Scanner used by TOMLParser TOMLTypes;

what does {$unitpath sources} do exactly in the file below? I assumed it added /sources to the directory the current file is in and then added that to the unit path like -Fu. If I omit the "in" part it still finds the units in /sources BUT then units in /sources can't find out units in /sources. For example TOMLParser can't find TOMLTypes even though they're in the same directory.

{$mode objfpc}
{$unitpath sources}
unit TOML;
interface
uses
  TOMLParser,
  TOMLTypes;

Regards,
Ryan Joseph

Reply by email