On 06.05.2011 17:58, Peter Williams wrote:
Hi,

Options changed, recompiling clean with -B
Hint: Start of reading config file /etc/fpc.cfg
Hint: End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 2.4.2-0 [2010/11/11] for i386
Copyright (c) 1993-2010 by Florian Klaempfl
Target OS: Linux for i386
Compiling island_maker.lpr
Compiling unit1.pas
unit1.pas(144,19) Error: Generics without specialization cannot be used
as a type for a variable
unit1.pas(152,1) Fatal: There were 1 errors compiling module, stopping

http://62.166.198.202/bug_view_advanced_page.php?bug_id=18101

(0043710)
Florian Klämpfl (administrator)
2010-11-29 10:47

        Please use always the latest release compiler (2.4.2) as starting
compiler to build a new fpc.


NB - I am using FPC 2.4.2.

type
Terrain_type = (Land, Sea);

exit_type = array[ directions ] of integer;

description_type = array[1..2] of string;

Tmap_detail = Object
FTerrain : Terrain_type;
FTerrain_char : char;
Fdescription : description_type;
Fx, Fy, Flocation_number : integer;
Fexits : exit_type;
end;

// The Island class definition
Generic TIsland<T> = class
Items : array of Tmap_detail;
public
constructor Create(AList: TList);: [Lazarus] dtm_maker project compile
errors with TList code.
procedure Add( Value : Tmap_detail );
end;
var
Form1: TForm1;
Island : TIsland; // line 144

Unit1.pas >>> http://pastebin.com/wuEft4Kb

Why do you declare TIsland as a generic if you don't use the type "T" anywhere?

Nevertheless, you need to declare a specialized type of a generic, so you're able to use it.

Example:

type
  TIntegerIsland = specialize TIsland<Integer>;

var
  Island: TIntegerIsland;
(...)

Regards,
Sven

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to