Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-19 Thread Paul Nicholls
- Original Message - From: "Tomas Hajny" To: ; "FPC-Pascal users discussions" Sent: Wednesday, November 18, 2009 10:40 PM Subject: Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable" On Tue, November 17, 2009

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-18 Thread Tomas Hajny
On Tue, November 17, 2009 10:48, Graeme Geldenhuys wrote: > dmitry boyarintsev wrote: >> >> procedure XorBlock(var InData1, InData2; Size: longword); >> var >> b1 : PByte; >> b2 ; PByte; > > Changing those declarations to PByteArray type solves the compiler error > in FPC. > > var > b1: PByte

Re[2]: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread JoshyFun
Hello Graeme, Tuesday, November 17, 2009, 11:15:09 AM, you wrote: GG> [...not that I fully understand the DCPCrypt code...] GG> Looking at your code and the rest of DCPCrypt code, it seems it already GG> optimized the calls to xorblock(), instead of inside xorblock() [...] That's not an "op

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Graeme Geldenhuys
dmitry boyarintsev wrote: > Seems like {$mode delphi} is used. Indeed it is. :) > here's faster version of xorblock [...not that I fully understand the DCPCrypt code...] Looking at your code and the rest of DCPCrypt code, it seems it already optimized the calls to xorblock(), instead of insid

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread dmitry boyarintsev
On Tue, Nov 17, 2009 at 12:48 PM, Graeme Geldenhuys wrote: > Changing those declarations to PByteArray type solves the compiler error > in FPC. Seems like {$mode delphi} is used. here's faster version of xorblock procedure XorBlockEx(var InData1, InData2; Size: longword); var l1 : PIntegerArra

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Graeme Geldenhuys
dmitry boyarintsev wrote: > > But, since we're using 32-bit processors it's more effective to use > 32-bit xor (where possible)! Out of interest... Could you explain "use 32-bit xor"? How does that differ to the code I posted? Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI to

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Graeme Geldenhuys
dmitry boyarintsev wrote: > > procedure XorBlock(var InData1, InData2; Size: longword); > var > b1 : PByte; > b2 ; PByte; Changing those declarations to PByteArray type solves the compiler error in FPC. var b1: PByteArray; b2: PByteArray; Regards, - Graeme - -- fpGUI Toolkit - a

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Graeme Geldenhuys
Jonas Maebe wrote: > > Indeed. In general, I'd recommend to always add a pointer typecast > though, to avoid problems in case the declared type should ever > change. Rather safe than sorry. I'll amend the code as such. Thanks for your help. Regards, - Graeme - -- fpGUI Toolkit - a cross-p

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Graeme Geldenhuys
dmitry boyarintsev wrote: > Graeme, why don't you use power of the FPC (and it's pointer maths)? > Pascal is language of readable code :) The original code is not mine, I'm simply making it 64-bit friendly and removing some compiler warnings where possible. > > procedure XorBlock(var InData1, In

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Jonas Maebe
On 17 Nov 2009, at 10:38, Graeme Geldenhuys wrote: > So in that case because a untyped parameters are treated like generic > Pointer types whereby arithmetic increments in byte size, I don't > actually need any type casts the parameters at all? Indeed. In general, I'd recommend to always add a p

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Graeme Geldenhuys
Jonas Maebe wrote: >> How to I solve this compiler hint? > > Don't cast ordinals to pointers. :-) > Replace the PtrUInt types casts with PByte (or Pointer) type casts. So in that case because a untyped parameters are treated like generic Pointer types whereby arithmetic increments in byte siz

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Graeme Geldenhuys
Aleksa Todorovic wrote: > > Does that mean that (PByte(p) + N) = (Pointer(p) + N) for > pointer-castable p and integer N? I believe it does. I read in the ref.pdf document that when you increment a generic Pointer type, it increments by 1 (equal to 1 byte). Regards, - Graeme - -- fpGUI Too

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Jonas Maebe
On 17 Nov 2009, at 10:17, Aleksa Todorovic wrote: > On Tue, Nov 17, 2009 at 10:05, Jonas Maebe wrote: >> >> Replace the PtrUInt types casts with PByte (or Pointer) type casts. >> > > Does that mean that (PByte(p) + N) = (Pointer(p) + N) for > pointer-castable p and integer N? Yes. The genera

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread dmitry boyarintsev
Graeme, why don't you use power of the FPC (and it's pointer maths)? Pascal is language of readable code :) procedure XorBlock(var InData1, InData2; Size: longword); var b1 : PByte; // in Delphi i'd use PByteArray b2 ; PByte; i: longword; begin b1:=...@indata1; b2:=...@indata2; for i:=

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Aleksa Todorovic
On Tue, Nov 17, 2009 at 10:05, Jonas Maebe wrote: > > Replace the PtrUInt types casts with PByte (or Pointer) type casts. > Does that mean that (PByte(p) + N) = (Pointer(p) + N) for pointer-castable p and integer N? ___ fpc-pascal maillist - fpc-pasca

Re: [fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Jonas Maebe
On 17 Nov 2009, at 10:02, Graeme Geldenhuys wrote: > How to I solve this compiler hint? Don't cast ordinals to pointers. > - > procedure XorBlock(var InData1, InData2; Size: longword); > var > i: longword; > begin > for i:= 1 to Size do >Pbyte(PtrUInt(@InDa

[fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

2009-11-17 Thread Graeme Geldenhuys
Hi, How to I solve this compiler hint? I've managed to get DCPCrypt compiled and running successfully (with my current tests) under 64-bit FPC & Linux. But I still have many compiler hints as listed below. Can I simply ignore them, or is there a way I can fix the code to remove the compiler warn