[fpc-pascal] Printing types in generics

Sven Barth pascaldragon at googlemail.com
Thu Oct 19 07:58:36 CEST 2017

Am 19.10.2017 07:45 schrieb "Ryan Joseph" <ryan at thealchemistguild.com>:
> How should you print types in generics for debugging? here’s an example
of how I’m doing it now but it’s hacky (forced type casting pointers) and
tkSString crashes like it is. There should be a better solution I think.

There isn't really a better solution, except that you could move that code
to a separate class or record so that you can use it in other
classes/record than TStaticArray as well...
And your case for tkSString crashes, because that is a ShortString, not a
AnsiString thus you need to cast to PShortString (best avoid "(P)String" in
this context as this could lead to different results depending on the
modeswitches). For the other string types you need to look at tkAString
(AnsiString), tkWString (WideString) and tkUString (UnicodeString).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20171019/15b43936/attachment.html>

More information about the fpc-pascal mailing list