Duplicate identifier "PT" in castleutils_struct_list in compiling on Lazarus

Good day!
I try to compile my project in another computer (to be exact, i temporally worked on another machine and now back to my usual workplace). When i do it from CGE editor it work nice. But when i trying to run project from Lazarus IDE, i got problem in castleutils_struct_list unit:

castleutils_struct_list.inc(27,12) Error: Duplicate identifier “PT”

  { List of structures.
    This is just TList class from Generics.Collections, with some useful helpers. }
  {$ifdef CASTLE_OBJFPC}generic{$endif}
  TStructList<T> = class({$ifdef CASTLE_OBJFPC}specialize{$endif} TList<T>)
      PT = ^T;
      TTypeList = array [0 .. {$ifdef FPC} MaxInt div SizeOf(T) - 1 {$else} 1000 * 1000 {$endif}] of T;
      PTypeList = ^TTypeList;

I see that error first time, and i remember, recently this code compiled from Lazarus fine. I think, problems started, when i move program to another computer.

I have a faint memory something like that happened to me before. I don’t remember how exactly I’ve fixed that but two things that may be useful to try:

  1. Rebuild the project clean from Lazarus (Run → Clean Up and Build…). If this helps, then this most likely was caused by upgrading CGE and Lazarus still keeping obsolete files somewhere around.
  2. It may be a bug in some specific Lazarus version. Though this happened to me a few years ago, so it should be a very obsolete one. But upgrading it won’t hurt unless it’s the latest one.
1 Like

@Noscow You are accidentally trying to compile a very ancient version of Castle Game Engine 6.4. You can see in castle-engine/castleutils_struct_list.inc at v6.4 · castle-engine/castle-engine · GitHub that it contains PT = ^T; line. It doesn’t compile with latest FPC/Lazarus.

The latest version of this file in Castle Game Engine 7.0-alpha.2 (and 7.0-alpha.1, and 7.0-alpha.snapshot… we fixed it a long time ago) looks like this: castle-engine/castleutils_struct_list.inc at master · castle-engine/castle-engine · GitHub . It has line PtrT = ^T;.

From your description, the most likely cause is that you had on your disk an old version of Castle Game Engine you downloaded a few years ago, and Lazarus remembers and reuses the package castle_base.lpk from there. To fix,

  • It should be enough if you just use “Preferences → Register Lazarus Packages” following the installation manual, Install | Manual | Castle Game Engine .

  • You can also just manually open and compile in Lazarus all CGE packages:

  • To avoid mistakes, I advise that you hunt down and delete the old Castle Game Engine 6.4 version from your disk. Look at Lazarus “Package → Install / Uninstall Packages…” window. In the bottom part of the window, you can see “Filename” – this is the path where Lazarus last heard about this package.


Thanks, now it work ok.
I think, last time i downloaded engine 7.0 from site, strange.