Recent

Author Topic: [SOLVED] Unit Types, shall I use it for non Windows OSes?  (Read 601 times)

ikel

  • New Member
  • *
  • Posts: 31
[SOLVED] Unit Types, shall I use it for non Windows OSes?
« on: July 28, 2024, 04:28:44 am »
I noticed this note when reading the official document of unit Types.

https://www.freepascal.org/docs-html/rtl/types/index.html

---

Starting with D6, types from Windows specific units that were needed in Kylix were extracted to this unit. So it mostly contains type of Windows origin that are needed in the VCL framework.

---

What does that mean? Can I ignore it if I am building on Ubuntu?
Thanks.
« Last Edit: July 29, 2024, 01:52:22 am by ikel »

Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
Re: Unit Types, shall I use it for non Windows OSes?
« Reply #1 on: July 28, 2024, 06:54:09 am »
Quote
What does that mean?

I've looked through the unit's sources and indeed it seems like it simply provides some types which are of no apparent value to me in a general case (don't take my words for granted, I've never used this unit myself, so I may be wrong). So most likely it means that if you are importing a program made in Kylix you need this unit to make it work.

Quote
Can I ignore it if I am building on Ubuntu?

If you are using this unit, then you need it, on Ubuntu too. Otherwise your program won't build as it requires a type defined in this unit. If you aren't using it, then you don't need it on Windows either.

If you received some program code that uses this unit, then most likely it's the first case and most likely your program won't run on Linux. If you are following a tutorial and the tutorial uses this unit, then most likely you'll need it during the next steps, so you need to include it and it will have problems working on Linux.

But if you are writing your own program, aiming at cross-platform development - then most likely you don't need it. Not "ignore it", just not use it.

Again, disclaimer, I haven't used this unit myself, so I may be wrong and it is required or offers significant simplification for some specific usecases.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

cdbc

  • Hero Member
  • *****
  • Posts: 1496
    • http://www.cdbc.dk
Re: Unit Types, shall I use it for non Windows OSes?
« Reply #2 on: July 28, 2024, 11:00:26 am »
Hi
I'm using FPC trunk, as my /daily driver/ and in 'trunk', 'TStrings' references types like 'TObjectDynArray' & 'TStringDynArray', e.g.:
Code: Pascal  [Select][+][-]
  1.     function ToObjectArray(aStart,aEnd : Integer) : TObjectDynArray; overload;
  2.     function ToObjectArray: TObjectDynArray; overload;
  3.     function ToStringArray(aStart,aEnd : Integer) : TStringDynArray; overload;
  4.     function ToStringArray: TStringDynArray; overload;
from 'Types'.
So I think, we're slowly getting married to 'Types', as 'trunk' is the next release version of FPC.
Regarding cross platform, see my sig.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11720
  • FPC developer.
Re: Unit Types, shall I use it for non Windows OSes?
« Reply #3 on: July 28, 2024, 11:16:01 am »
Simple Windows types like TRect and TPoint were needed outside of windows specific and VCL specific units (also for CLX).  So they were moved to types.

A decade later the same happened again when pretty generic color types (like TColor and TRGB etc) were factored out of graphics into system.uitypes.

In general, if such generic types are better used from unit "types', it has been two decades, it is normal now.
« Last Edit: July 28, 2024, 01:17:42 pm by marcov »

ikel

  • New Member
  • *
  • Posts: 31
Re: Unit Types, shall I use it for non Windows OSes?
« Reply #4 on: July 28, 2024, 12:24:33 pm »
Thanks everyone.

@marcov, thanks for the history behind it.
I'll make a note to use Types from now on where possible.

@cdbc, thanks for mentioning about the use of Types in trunk.

@Eugene Loza, thanks for pointing out on 'ignore' vs 'no need to use it' ...  :D

Cheers,
Ikel

 

TinyPortal © 2005-2018