user19800284
user19800284

Reputation:

Is there a way of uniting Units in Delphi?

I have a bunch of records defined into a few files.

I'd like to "unite" those definitions into a single unit, and use that unit everywhere in my program, to avoid having to reference all these units one by one in the rest of the program. Is there a way to do so in Delphi (without actually putting everything in one file)?

Something that would allow me to tell the compiler "if a file uses Unit1, it can use Unit2 too without directly referencing it".

Upvotes: 0

Views: 351

Answers (1)

Marco van de Voort
Marco van de Voort

Reputation: 26358

If it is just to make maintaining unit lists easier you can use type aliases, like in unit2's interface do

Uses Unit1 
Type
   TMyBaseType = Unit1.TMyBaseType;

Now if you import unit2, the relevant type of unit1 is also visible.

Upvotes: 1

Related Questions