[fpc-pascal] Make a distinct pointer type
Michael Van Canneyt
michael at freepascal.org
Wed May 31 16:20:26 CEST 2023
On Wed, 31 May 2023, Hairy Pixels via fpc-pascal wrote:
> What's the best way to make a pointer type which is distinct so that the following snippet would give an error. I thought "type pointer" would do it but it doesn't seem to work.
> PA = type pointer;
> PB = type pointer;
> a: PA;
> b: PB;
> a := b; // should give an error!
Type aliases are always assignment compatible.
As far as I know, there is no way to do what you want with just 'pointer'.
This will give an error:
RA = record end;
RB = record end;
PA = ^RA;
PB = ^RB;
a := b;
More information about the fpc-pascal