Home > database >  Is there a way of uniting Units in Delphi?
Is there a way of uniting Units in Delphi?

Time:10-17

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".

CodePudding user response:

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.

  • Related