[fpc-pascal] Printing of Pointer Type

Johann Glaser Johann.Glaser at gmx.at
Thu Jul 17 22:01:00 CEST 2008


Hi!

Am Donnerstag, den 17.07.2008, 21:52 +0200 schrieb Mattias Gaertner:
> On Thu, 17 Jul 2008 10:45:22 +0200
> "Vinzent Höfler" <JeLlyFish.software at gmx.net> wrote:
> 
> > leledumbo <leledumbo_cool at yahoo.co.id>
> > > 
> > > Jonas Maebe-2 wrote:
> > > > 
> > > > Because there are easy ways around it (as you mention) and the
> > > > work to implement and maintain this would probably outweigh the
> > > > usefulness.
> > > > 
> > > Yes, it's easy but uncomfortable and needs more typing.
> > 
> > Well, sure, but printing pointer values in most cases is a pure
> > debugging aid and nothing really useful.
> 
> Well. Since the biggest time of programming is spent on debugging I
> guess, there is more need for a PtrToStr than for FloatToStr.

I suggest to extend Write and WriteLn, that for Pointer typed parameters
those are printed in hex, e.g.

Var Edit : TEdit;
Begin
  Edit := TEdit.Create;
  WriteLn('Edit = ',Pointer(Edit));
End

then prints to the screen

  Edit = $B0283958

Would be very handy for debugging, similar like C++'s 
  cout << "Edit = " << (void*)Edit << endl;
(okok, streams are ugly syntax at least, but the overloaded operator for
untyped (void) pointers comes in handy instead of FreePascal's
IntToHex(PtrUInt(Edit),8)

Bye
  Hansi





More information about the fpc-pascal mailing list