At 20:34 20-12-2004, [EMAIL PROTECTED] wrote:

On Mon, 20 Dec 2004, Peter Vreman wrote:

> >>>>> Hi,
> >>>>>
> >>>>> From what I understand from the definition of THandle in
> >>>>> 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.

I guess this is supposed to be "64-bit on 64-bit platforms" ?

Guess so :)

In general, Peter is right,

(sorry, I couldn't resist :)

and it would be better to introduce a
separate type for the 'windows handle': TWinHandle or TLCLHandle
which is platform dependent.

I've been thinking of a TLCLHandle, but one of the goals of Lazarus is to keep Delphi apps easy portable. And replacing all THandles with TLCLHandle doesn't sound very port friendly to me. Besides, since THandle is defined in system, if someone forgets to change it, the ported app will probably compile with only a easy to miss warning, whith all resulting errors.
But I understand that this has nothing to with the choice of a THandle beeing 32 bit.

OTOH, We could also reverse the argument and introduce TFileHandle, so as to
clearly mark the fact that it is for files only...

That would be my choice also.
For me a THandle is a generic abstract identifier, which can identify a file, a window, a process, a thread, a event, a bitmap, a pen, a brush, a region, a font, a DC, a whatever_I_forgot_more
THandle is used as basetype for all these types of handles. And personally I think it is a bit limitted to use it only for a filehandle.


_______________________________________________ fpc-devel maillist - [EMAIL PROTECTED]

Reply via email to