[fpc-pascal] Make a distinct pointer type

Hairy Pixels genericptr at gmail.com
Sat Jun 3 05:38:14 CEST 2023


I just noticed this still doesn't provide good type safety as MyPtr can be assigned an untyped pointer. Are pointers simply not an option here? Maybe we need classes for opaque pointer types instead?

type
  _MyPtr = record end;
  MyPtr = ^_MyPtr;
var
  p: Pointer;
  x: MyPtr;
begin
  x := p; // Should be an error!
end;

Regards,
Ryan Joseph



More information about the fpc-pascal mailing list