Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2024-01

"Address of" question

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Hairy Pixels

I just noticed it's possible to do @Byte in FPC. Are these 2 lines even different? It doesn't exactly make sense to take the address of a type identifier so I'm curious what this may mean.

var
  b: Byte;
  p: PByte;
begin
  p := @Byte(b);
  p := PByte(@b);

Regards,
Ryan Joseph

Reply by email

Michael Van Canneyt
to Hairy Pixels
Hairy Pixels wrote 7 lines
I just noticed it's possible to do @Byte in FPC. Are these 2 lines even different? It doesn't exactly make sense to take the address of a type identifier so I'm curious what this may mean. var b: Byte; p: PByte; begin p := @Byte(b);

This is a typecast of b from which you take the address. The typecast is superfluous.

will have the same effect.

Michael.

Reply by email