Re: [fpc-pascal] THandle in code that must compile also with Delphi

2014-03-20 Thread Juha Manninen
On Thu, Mar 20, 2014 at 3:25 PM, Virgo Pärna wrote: > I did try googling and it appears, that in 64 bit Delphi XE2 uses THandle > as a result type. Anyway, in the case of error, it returns > INVALID_HANDLE_VALUE, > which is DWORD(-1). >So, under Windows it would be possible to use same co

Re: [fpc-pascal] THandle in code that must compile also with Delphi

2014-03-20 Thread Marco van de Voort
In our previous episode, Mark Morgan Lloyd said: > > IMHO the universal handle (for e.g. IPC related handles and file handles) is > > not a portable concept to begin with. > > I think the concept of a handle as an opaque type is universal. What > isn't safe is any assumption of consistent behavio

Re: [fpc-pascal] THandle in code that must compile also with Delphi

2014-03-20 Thread Mark Morgan Lloyd
Marco van de Voort wrote: IMHO the universal handle (for e.g. IPC related handles and file handles) is not a portable concept to begin with. I think the concept of a handle as an opaque type is universal. What isn't safe is any assumption of consistent behaviour, e.g. that select() may be ap

Re: [fpc-pascal] THandle in code that must compile also with Delphi

2014-03-20 Thread Virgo Pärna
On Thu, 20 Mar 2014 13:02:28 +0100 (CET), Michael Van Canneyt wrote: > > Shortly said: No. The Delphi API is wrong; It should also return THandle > (as that is what Windows CreateFile returns), but probably for historical > reasons they still use Integer. > With the advent of 64-bit delphi, th

Re: [fpc-pascal] THandle in code that must compile also with Delphi

2014-03-20 Thread Michael Van Canneyt
On Thu, 20 Mar 2014, Marco van de Voort wrote: In our previous episode, Michael Van Canneyt said: Question: what is the best way to maintain code that must compile with both FPC and Delphi2007? The obvious solution is to use IFDEF and define a new type, say TMyHandle. FPC's libraries however

Re: [fpc-pascal] THandle in code that must compile also with Delphi

2014-03-20 Thread Marco van de Voort
In our previous episode, Michael Van Canneyt said: > > Question: what is the best way to maintain code that must compile with > > both FPC and Delphi2007? > > The obvious solution is to use IFDEF and define a new type, say TMyHandle. > > FPC's libraries however take care of many platform difference

Re: [fpc-pascal] THandle in code that must compile also with Delphi

2014-03-20 Thread Michael Van Canneyt
On Thu, 20 Mar 2014, Juha Manninen wrote: FileCreate and FileOpen return THandle with FPC but integer with Delphi2007. Delphi defines THandle as LongWord but for some reason Integer is used instead. With FPC on a 64-bit system THandle is 64- bit unsigned. Question: what is the best way to mai

[fpc-pascal] THandle in code that must compile also with Delphi

2014-03-20 Thread Juha Manninen
FileCreate and FileOpen return THandle with FPC but integer with Delphi2007. Delphi defines THandle as LongWord but for some reason Integer is used instead. With FPC on a 64-bit system THandle is 64- bit unsigned. Question: what is the best way to maintain code that must compile with both FPC and