[SOLVED] Type inheritance lazarus / 21-General ---------------------------------------------------------------------- pcurtis · 2022-01-31 11:55 I have a unit (X) where an enumerated type (TMyEnum) is defined. I create a component (MyComponent) that uses that unit. When I create a project that uses MyComponent I need to reference TMyEnum. I can solve this by adding X to the uses clause. This means I have to add X to the uses clause of every project that uses MyComponent. I don't want to do that. Is there a better way to inherit TMyEnum? ---------------------------------------------------------------------- SymbolicFrank · 2022-01-31 12:05 Yes, make a separate unit for constants and types you want to include in every other unit. ---------------------------------------------------------------------- pcurtis · 2022-01-31 12:08 Doesn't that just move the problem to another unit? ---------------------------------------------------------------------- Zvoni · 2022-01-31 12:09 Another way could be to use includes in the Interface-Section of MyComponent From the docs (https://www.freepascal.org/docs- html/ref/refsu102.html): QuoteAll identifiers in the interface part of a unit are valid from the point of declaration, until the end of the unit. Furthermore, the identifiers are known in programs or units that have the unit in their uses clause. Identifiers from indirectly dependent units are not available. ---------------------------------------------------------------------- Warfley · 2022-01-31 12:28 You can add a same name alias in your unit: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // unit Atype TMyEnum = (...);// Unit B:type TMyEnum = A.TMyEnum; procedure Foo(value: TMyEnum); ---------------------------------------------------------------------- Thaddy · 2022-01-31 12:40 dot Dot like in . ---------------------------------------------------------------------- pcurtis · 2022-01-31 12:51 I can't figure this out. I've attached the project if it helps. ---------------------------------------------------------------------- Thaddy · 2022-01-31 12:54 https://www.imdb.com/title/tt0112697/ ---------------------------------------------------------------------- Zoran · 2022-01-31 13:31 Quote from: pcurtis on January 31, 2022, 12:55:32 pmI have a unit (X) where an enumerated type (TMyEnum) is defined. I create a component (MyComponent) that uses that unit. When I create a project that uses MyComponent I need to reference TMyEnum. I can solve this by adding X to the uses clause. This means I have to add X to the uses clause of every project that uses MyComponent. I don't want to do that. Is there a better way to inherit TMyEnum? First, let's see, we have these five statements as facts: - you have unit X where TMyEnum is declared - you have a unit where TMyComponent is declared (let's say it's unit Y) - you have a unit where you use TMyComponet (let's say it's unit Z) - as TMyComponent needs TMyEnum, you had to include X in uses section of unit Y. - as you use TMyComponent in unit Z, you had to include Y in uses section of unit Z. You want to avoid adding X to uses section of unit Z (and any other unit where you use TMyComponent). The advice you got in posts above says that, in interface section of unit Y, you can declare Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TMyEnum = X.TMyEnum;  Then you will not need to include X in Z to be able to reference TMyEnum. Okay? ---------------------------------------------------------------------- pcurtis · 2022-01-31 14:16 Got it. Thanks.