Re[2]: [fpc-pascal] How to solve "variable does not seem to be initialized" compiler hint.

2009-11-17 Thread JoshyFun
Hello FPC-Pascal,

Tuesday, November 17, 2009, 8:47:03 PM, you wrote:

c> Can the Fill... functions be changed to have the first parameter "out"
c> instead of "var" ? Surely they don't use it as an input parameter.

Write your own "fillchar" like function and inline it, something like:

procedure MyFillChar(out x; count: SizeInt; Value: char); inline;
begin
{$PUSH}
{$HINTS OFF}
  FillChar(x,count,Value);
{$POP}
end;

-- 
Best regards,
 JoshyFun

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to solve "variable does not seem to be initialized" compiler hint.

2009-11-17 Thread Jonas Maebe

On 17 Nov 2009, at 20:47, cobines wrote:

> Can the Fill... functions be changed to have the first parameter "out"
> instead of "var" 

No: http://lists.freepascal.org/lists/fpc-devel/2009-November/018532.html


Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re[2]: [fpc-pascal] How to solve "variable does not seem to be initialized" compiler hint.

2009-11-17 Thread Fantomas
>> In my humble opinion, there are no problems with the FillChar declaration.
>> But the way you wrote your _absolutely correct_ code produced a hint. You
>> shold use $HINTS OFF, for amendment to the FillChar declaration seems to be
>> done unlikely.

> But there is a reason for the hints. It should point you to possible problems
> (or optimitations). When switching it off, you also loose all other hints.
> That's not a solution, it's a workaround.

As far as I know $HINTS is a local directive. So, you can circumscribe only a
certain piece of your code. E.g:

{$HINTS OFF}
FillChar(Temp,SizeOf(Temp),0);
{$HINTS ON}

You may consider my point to be a bit conservative, but I really do not think
there is something to change about the FillChar declaration.

--
Best regards,
Fantomas

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to solve "variable does not seem to be initialized" compiler hint.

2009-11-17 Thread cobines
Can the Fill... functions be changed to have the first parameter "out"
instead of "var" ? Surely they don't use it as an input parameter.

--
cobines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] question about FpTimes in BaseUnix package

2009-11-17 Thread Rainer Stratmann
Am Tuesday 17 November 2009 19:34:19 schrieb Bruce Bauman:
> I am using the FpTimes function from the BaseUnix package. The
> documentation says it returns -1 on an error, otherwise the number of
> clock ticks since boot time.

What does clock ticks exactly mean?
I am searching for an equivalent to getticks in windows.
Rainer
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] question about FpTimes in BaseUnix package

2009-11-17 Thread Jonas Maebe

On 17 Nov 2009, at 19:34, Bruce Bauman wrote:

> I am using the FpTimes function from the BaseUnix package. The
> documentation says it returns -1 on an error, otherwise the number of
> clock ticks since boot time. However, the return type of this function
> is TClock, which is unsigned.

From "man 3 times":

If an
error occurs, times() returns the value ((clock_t)-1), and sets errno to
indicate the error.

So check against TClock(-1).


Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] question about FpTimes in BaseUnix package

2009-11-17 Thread Bruce Bauman
I am using the FpTimes function from the BaseUnix package. The
documentation says it returns -1 on an error, otherwise the number of
clock ticks since boot time. However, the return type of this function
is TClock, which is unsigned.

This, if I say:

X := BaseUnix.FpTimes(T);

if (X <> -1) then ...

I get a compiler-time warning (range check error while evaluating
constants).

Should the return type not be unsigned? Is checking the result against
-1 OK?

-- Bruce 
CONFIDENTIALITY NOTICE: This e-mail is confidential and intended
solely for the use of the individual or entity to which it is addressed.  If
you are not the intended recipient, be advised that you have received 
this email in error and that any use, dissemination, forwarding, printing 
or copying of this e-mail is strictly prohibited. If you received this e-mail
in error, please delete it from your computer and contact the sender.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Web interface for public.mseide-msegui.talk

2009-11-17 Thread Martin Schreiber
Hi,
Wahono activated a web interface with search function for 
public.mseide-msegui.talk:
http://msegui.org/fudforum/index.php?t=thread&frm_id=2&S=a0f13320c71aa14a269ca8b4d05f4631

Martin
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to solve "variable does not seem to be initialized" compiler hint.

2009-11-17 Thread Jürgen Hestermann

In my humble opinion, there are no problems with the FillChar declaration. But
the way you wrote your _absolutely correct_ code produced a hint. You shold use
$HINTS OFF, for amendment to the FillChar declaration seems to be done unlikely.


But there is a reason for the hints. It should point you to possible problems 
(or optimitations). When switching it off, you also loose all other hints. 
That's not a solution, it's a workaround.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: [fpc-devel] Installing "fpc-2.4.0-0.rc1.src.rpm" to OpenSuse 11.2

2009-11-17 Thread Joost van der Sluis
On Tue, 2009-11-17 at 06:48 +0700, Paul Ishenin wrote:
> Juha Manninen wrote:
> > I am planning to use this svn version for Lazarus experiments.
> > Is it a good idea?
> >   
> not bad. use also lazarus trunk for experiments.
> > I selected the compiler and executable there but Lazarus complained about 
> > fpc.cfg (and such) and doesn't work.
> >   
> we need exact error message to help you
> > Maybe I will ask later from Lazarus list
> indeed good decision.

How to install fpc? Better ask here.

After 'make all' you have to do a 'make install'. If you do that as root
it will install the new fpc system-wide. Maybe you don't need to adapt
your fpc.cfg in that case. (You can find it in /etc/fpc.cfg)

Joost

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re[2]: [fpc-pascal] How to solve "variable does not seem to be initialized" compiler hint.

2009-11-17 Thread Fantomas
Hello, Graeme!

Tuesday, November 17, 2009, 2:20:18 PM, you wrote:

> That you.  I agree with JoshyFun though. It seems like it is actually a
> problem in the FillChar() definition and that should be fixed, instead of
> simply ignoring the hint.

> I raised this issue in the fpc-devel mailing list.

In my humble opinion, there are no problems with the FillChar declaration. But
the way you wrote your _absolutely correct_ code produced a hint. You shold use
$HINTS OFF, for amendment to the FillChar declaration seems to be done unlikely.


--
Best regards,
Fantomas

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to solve "variable does not seem to be initialized" compiler hint.

2009-11-17 Thread Graeme Geldenhuys
Fantomas wrote:
> 
> That compiler hint appears because you have not assigned a value to the 
> variable
> Temp before passing it to a function as a parameter. You can pay no attention 
> to
> that hint or switch off hints in your code where the hint is produced, if it
> really bothers you.

That you.  I agree with JoshyFun though. It seems like it is actually a
problem in the FillChar() definition and that should be fixed, instead
of simply ignoring the hint.

I raised this issue in the fpc-devel mailing list.

Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to solve "variable does not seem to be initialized" compiler hint.

2009-11-17 Thread Fantomas
Hello, Graeme!

Tuesday, November 17, 2009, 1:03:22 PM, you wrote:

> And how do I solve this compiler hint?  Normally I use FillChar(), but here it
> made no difference. The hint no simply moved to the line containing FillChar()
> call. :-(


> /home/graemeg/programming/3rdParty/DCPcrypt/dcpblockciphers.pas(229,16)
> Hint: Local variable "Temp" does not seem to be initialized


>   p2:= @Outdata;
>   FillChar(Temp, SizeOf(Temp), 0); // <-- I added this to no affect
>   for i:= 1 to Size do
>   begin
> TempByte:= p1^;
> EncryptECB(CV,Temp);  // <- original hint was here
> p2^:= p1^ xor Temp[0];
> Move(CV[1],CV[0],8-1);
> CV[7]:= TempByte;


That compiler hint appears because you have not assigned a value to the variable
Temp before passing it to a function as a parameter. You can pay no attention to
that hint or switch off hints in your code where the hint is produced, if it
really bothers you.


--
Best regards,
Fantomas

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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 "optimization" it is a need because the EncryptECB can
only work over 64 bits blocks, so the last block must be "padded".
Also in 64 bits it should use 64 bits access to the array, not 32 bits
always. In the "xorblockex" changing "LongWord" by "SizeUInt" and
"PIntegerArray" by "PSizeUintArray" (which definition seems to not
exist) should do the trick.

-- 
Best regards,
 JoshyFun

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to solve "variable does not seem to be initialized" compiler hint.

2009-11-17 Thread JoshyFun
Hello Graeme,

Tuesday, November 17, 2009, 11:03:22 AM, you wrote:

GG> /home/graemeg/programming/3rdParty/DCPcrypt/dcpblockciphers.pas(229,16)
GG> Hint: Local variable "Temp" does not seem to be initialized
[...]
GG> raise EDCP_blockcipher.Create('Cipher not initialized');
GG>   p1:= @Indata;
GG>   p2:= @Outdata;

Insert this, or in other words "use it". The reason is that "fillchar"
first parameter is "var" instead "out".

Temp[0]:=0;

GG>   FillChar(Temp, SizeOf(Temp), 0); // <-- I added this to no affect
GG>   for i:= 1 to Size do

-- 
Best regards,
 JoshyFun

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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 inside xorblock()

Here is an example of a method using xorblock().


procedure TDCP_blockcipher64.EncryptCBC(const Indata; var Outdata;
Size: longword);
var
  i: longword;
  p1, p2: pointer;
begin
  if not fInitialized then
raise EDCP_blockcipher.Create('Cipher not initialized');
  p1:= @Indata;
  p2:= @Outdata;
  for i:= 1 to (Size div 8) do
  begin
Move(p1^,p2^,8);
XorBlock(p2^,CV,8);
EncryptECB(p2^,p2^);
Move(p2^,CV,8);
p1:= pointer(p1 + 8);
p2:= pointer(p2 + 8);
  end;
  if (Size mod 8)<> 0 then
  begin
EncryptECB(CV,CV);
Move(p1^,p2^,Size mod 8);
XorBlock(p2^,CV,Size mod 8);
  end;
end;


Either way, to scratch my own itch, I am going to put together a small
example app calling the original xorblock() and your xorblockex()
recursively and do some timing around them to see the speed difference.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] How to solve "variable does not seem to be initialized" compiler hint.

2009-11-17 Thread Graeme Geldenhuys
Hi,

And how do I solve this compiler hint?  Normally I use FillChar(), but
here it made no difference. The hint no simply moved to the line
containing FillChar() call. :-(


/home/graemeg/programming/3rdParty/DCPcrypt/dcpblockciphers.pas(229,16)
Hint: Local variable "Temp" does not seem to be initialized


---
procedure TDCP_blockcipher64.DecryptCFB8bit(const Indata; var Outdata;
Size: longword);
var
  i: longword;
  p1, p2: Pbyte;
  TempByte: byte;
  Temp: array[0..7] of byte;
begin
  if not fInitialized then
raise EDCP_blockcipher.Create('Cipher not initialized');
  p1:= @Indata;
  p2:= @Outdata;
  FillChar(Temp, SizeOf(Temp), 0); // <-- I added this to no affect
  for i:= 1 to Size do
  begin
TempByte:= p1^;
EncryptECB(CV,Temp);  // <- original hint was here
p2^:= p1^ xor Temp[0];
Move(CV[1],CV[0],8-1);
CV[7]:= TempByte;
Inc(p1);
Inc(p2);
  end;
end;
---



Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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 : PIntegerArray;
  l2 : PIntegerArray;
  b1 : PByteArray;
  b2 : PByteArray;
  i  : integer;
  c  : integer;
begin
  l1:=...@indata1;
  l2:=...@indata2;
  for i:=0 to size div sizeof(LongWord)-1 do
l1[i]:=l1[i] xor l2[i];

  // the rest of the buffer (3 bytes)
  c:=size mod sizeof(longWord);
  if c>0 then begin
b1:=...@indata1;
b2:=...@indata2;
for i:=(size-c) to size-1 do b1[i]:=b1[i] xor b2[i];
  end;
end;

thanks,
dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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 toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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 cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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, InData2; Size: longword);
> var
>   b1 : PByte; // in Delphi i'd use PByteArray
>   b2 ; PByte;
>   i: longword;
> begin
>   b1:=...@indata1;
>   b2:=...@indata2;
>   for i:=0 to size-1 do
> b1[i]:=b1[i] xor b2[i];

 ^  ^^
dcpcrypt2.pas(660,9) Error: Array type required

You are the second person to recommend something like this and every
time I get compiler errors. I am using 64-bit FPC 2.4.0-rc1 under Linux.


But yes, your code is indeed more readable. :-)



> But, since we're using 32-bit processors it's more effective to use
> 32-bit xor (where possible)!

I'm not using 32-bit processors. That's the whole reason for the
modifications to DCPCrypt code - getting it 64-bit compatible.



Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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 pointer typecast though, to 
avoid problems in case the declared type should ever change.


Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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 size, I don't
actually need any type casts the parameters at all?  Is the code below
safe?  It seem to work fine in our projects and data.


procedure XorBlock(var InData1, InData2; Size: longword);
var
  i: longword;
begin
  for i:= 1 to Size do
Pbyte(@InData1+i-1)^ :=
   Pbyte(@InData1+i-1)^ xor
   Pbyte(@InData2+i-1)^;
end;



Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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 Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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 general rule is that adding an ordinal N to a pointer type P increases 
P by the size of the type this pointer points to times N. Sizeof(pbyte^) = 
sizeof(byte) = 1. 

Pointer is a special case since it's untyped (sizeof(pointer^) = 0 in the FPC), 
and adding an ordinal N to an untyped pointer also increases its value by N.


Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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:=0 to size-1 do
b1[i]:=b1[i] xor b2[i];
end;

But, since we're using 32-bit processors it's more effective to use
32-bit xor (where possible)!

thanks,
dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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(@InData1)+i-1)^ :=
>   Pbyte(PtrUInt(@InData1)+i-1)^ xor
>   Pbyte(PtrUInt(@InData2)+i-1)^;
> end;

Replace the PtrUInt types casts with PByte (or Pointer) type casts.


Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[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
warning.  How serious is this hint?


/home/graemeg/programming/3rdParty/DCPcrypt/dcpcrypt2.pas(653,37) Hint:
Conversion between ordinals and pointers is not portable


-
procedure XorBlock(var InData1, InData2; Size: longword);
var
  i: longword;
begin
  for i:= 1 to Size do
Pbyte(PtrUInt(@InData1)+i-1)^ :=
   Pbyte(PtrUInt(@InData1)+i-1)^ xor
   Pbyte(PtrUInt(@InData2)+i-1)^;
end;
-

 1 2 3 4 5 6 7
123456789012345678901234567890123456789012345678901234567890123456789012345


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal