Forum > FPC development

TypeInfo() - what is it?

<< < (3/3)

Thaddy:

--- Quote from: ASerge on November 30, 2022, 10:14:41 pm ---
--- Quote from: beria on November 30, 2022, 03:32:31 pm ---Or maybe I'm missing something in the implementation of this function, and it's still not an internal compiler function, as it's written in the description, or FPC somehow allows you to change the variable's type, which is totally insane to me?

--- End quote ---
Use GetTypeKind:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure test40(a: PtrUint); inline;begin  if GetTypeKind(a) = GetTypeKind(Byte) then    Writeln('BYTE');end;
--- End quote ---

No, this would only work for your expected result on x86_64 and not on x86_32 a.k.a i386.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var a:ptruint;begin writeln(GetTypeKind(a) = GetTypeKind(Byte));  // returns true on 32 bit and false on 64 bitend.
On 32 bit GetTypeKind(a) returns tkInteger as does GetTypeKind(byte)
On 64 bit GetTypeKind(a) returns tkQword.............

Btw: tkInteger is correct for 32 bit. It does not have to explain signed or not.


Navigation

[0] Message Index

[*] Previous page

Go to full version