[fpc-devel] THandle and 64bit platforms

Peter Vreman peter at freepascal.org
Mon Dec 20 19:53:26 CET 2004


>>>>> Hi,
>>>>>
>>>>> From what I understand from the definition of THandle in
>>>>> sysunixh.inc it is defined as a LongInt, even on 64 bit platforms.
>>>>> Currently I'm porting Lazarus to x64 and there I need a 64bit
>>>>> THandle, how to solve it ?
>>>>
>>>>File descriptors are still 32bit on x86_64, therefor Thandle=32bit.
>>>
>>> A THandle is more than a file descriptor alone.
>>> Since the LCL is VCL compatible and thus MS biassed, there are more
>>> THandles than filedescriptors alone. To keep code compatible
>>and portable,
>>> I need a 64 bit THandle on 64 bit platforms. (on win64 a handle is also
>>> 64bit).
>>> Or would you suggest to use HANDLE for a 64bit handle and THandle for
>>> 32bit ?
>>
>>THandle is platform dependent. On win64 THandle=QWord.
>>
>>Currently Thandle=longint for unix, but Thandle=DWord for win32.
>
> Yes, I am aware of that, my question however is is how to get things
> working.
>
> In the LCL a THandle is used everywhere and in most cases it represents a
> pointer. It is also part of the emulated message records. All members of
> it are defined as PtrInt. On placed where a handle is iused, it should map
> on a PtrInt.
>
> Woudl you suggest me to
>   a) forbid the use of thandle
>   b) change all records and places where thandle is used
>   c) create a intermediate function which maps a handle to a pointer
>      (and still change a load of records)

The RTL should stay clean of Windows specific issues.THandle is defined as
the same type as filedescriptors on the target OS. When you need some
handle for Windows emulation you can create your own type TLCLHandle that
will be 64bit for all platforms.










More information about the fpc-devel mailing list