Search code examples
delphigenericslazarustobjectlist

Lazarus cannot find Uses Generics


Why can't I uses Generics.Collections or Generics.Default or even just Generics in Lazarus?

Uses
  Generics.Collections;

Uses
  System.Generics.Default;

Uses
  System.Generics.Collections;

Uses
  System.Generics.Default,
  System.Generics.Collections;

Uses
  SysUtils,
  Generics;    

Cannot find Generics.Collections used by uTest of the Project Inspector.
Cannot find Generics.Defaults used by uTest of the Project Inspector.
Cannot find Generics used by uTest of the Project Inspector.


Solution

  • Lazarus is the IDE for the open-source FreePascal compiler. Neither of them have ANYTHING to do with Delphi. FreePascal is a completely separate Pascal compiler than the one Delphi uses.

    FreePascal has a Delphi compatibility mode, and does implement various Delphi units and classes, to help users port existing Delphi code to FreePascal.

    But as far as Generics is concerned, FreePascal provides its own Generics syntax and implementation that is different from, and not compatible with, Delphi's Generics (actually, support for Delphi-style Generics was added in FreePascal 2.6, but "still may be not 100% compatible" with Delphi. Also see delphi language features which fpc does not have - Generics Syntax).

    Read FreePascal's documentation for more details about its flavor of Generics:

    http://wiki.freepascal.org/Generics

    http://www.freepascal.org/docs-html/ref/refch8.html

    The System.Generics.Default and System.Generics.Collections units are only available in Delphi, they do not exist in FreePascal. However, there is a 3rd party implementation of these units available for FreePascal.