Hi,
According to the note in chapter 2, section 2.2.1 of the FPC Programmer's
Guide, it is not possible for conditionals to be exported to other units.
Is there a way around this?
My Ref:
Programmer's Guide for Free Pascal, Version 2.2.2
Document version 2.0
June 2008
Regards,
Nino
_
TCommsBuffer = packed record
UnitID: Byte;
FunctionCode: TModBusFunction;
MBPData: TModBusDataBuffer;
Spare: Byte;
end; { TCommsBuffer }
SendBuffer: TCommsBuffer;
--
I want to send the data in SendBuffer to serial port
I define a array type:
rcvData:TDa
Hi,
either use "Move( SendBuffer, rcvData, count )" (recommended since its
from rtl, not windows api) or
"CopyMemory( @rcvData[0], @SendBuffer, count )".
Its a common mistake to use @ instead of @[ 0 ].
regards
On Sat, Oct 10, 2009 at 11:51 AM, yu ping wrote:
> TCommsBuffer = packed record
>
Hi,
For the Move solution, use "Move( SendBuffer, rcvData[0], count )"..
Same common mistake with [0].
sry
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Solved,Thanks
there is another mistake:
FillChar(sendData, high(sendData), 0);
change to
FillChar(sendData[0], high(sendData), 0);
OK.
2009/10/10 Matthias K. :
> Hi,
> For the Move solution, use "Move( SendBuffer, rcvData[0],
Its a common mistake to use @ instead of @[ 0 ].
IMO this happens because of an illogical design flaw (which seems to be
introduced by Borland). If I have a variable that is a *pointer* to an
array then why is it possible to use the square brackets to use it as if
it was an array? The derefe
2009/10/10 Jürgen Hestermann :
>> Its a common mistake to use @ instead of @> array var>[ 0 ].
>
> IMO this happens because of an illogical design flaw (which seems to be
> introduced by Borland). If I have a variable that is a *pointer* to an array
> then why is it possible to use the square brack
This behaviour comes from C syntax. The array is a pointer, which you
dereference by using the square brackets. This is well defined
syntax, nothing automatic or illogical about it. The only reason
pascal programmers make mistakes with this is because they are less
accustomed to using pointers.
2009/10/10 Jürgen Hestermann :
>
> It is illogical that I am able to enumerate a pointer as if it was an array.
> So the brackets do the dereferencing automatically. When I write X[1] it
> assumes I meant X^[1]. To the user it behaves the same as if X was an array
> instead of a pointer to an array
2009/10/10 Jürgen Hestermann :
>
> It is illogical that I am able to enumerate a pointer as if it was an array.
> So the brackets do the dereferencing automatically. When I write X[1] it
> assumes I meant X^[1]. To the user it behaves the same as if X was an array
> instead of a pointer to an array
2009/10/10 Jürgen Hestermann :
>
> It is illogical that I am able to enumerate a pointer as if it was an array.
> So the brackets do the dereferencing automatically. When I write X[1] it
> assumes I meant X^[1]. To the user it behaves the same as if X was an array
> instead of a pointer to an array
In our previous episode, Henry Vermaak said:
[ Charset ISO-8859-1 unsupported, converting... ]
> 2009/10/10 J?rgen Hestermann :
> >
> > It is illogical that I am able to enumerate a pointer as if it was an array.
> > So the brackets do the dereferencing automatically. When I write X[1] it
> > assum
2009/10/10 Marco van de Voort :
>> http://en.wikipedia.org/wiki/C_syntax#Accessing_elements
>
> That link is talking about interchangability, which is not the same as being
> the same.
Yes, I'm just trying to explain that there's no magic to it,
illustrated by some basic pointer arithmetic.
Henry
In our previous episode, Henry Vermaak said:
> >
> > That link is talking about interchangability, which is not the same as being
> > the same.
>
> Yes, I'm just trying to explain that there's no magic to it,
> illustrated by some basic pointer arithmetic.
I think there are several bits that mix
Also, it is very important to make distinction between static and
dynamic arrays. For static arrays, compiler knows their exact memory
location at compile time (modulo situations where static array is part
of another structure), but for dynamic arrays, compiler only knows
where in memory is referen
Henry Vermaak wrote:
One thing I think you don't understand is that an array _is_ a
pointer. Look at this table to visualise:
In Pascal, an array is not a pointer; at least not at the language
level. For a static array X (array[1..n] of T), you *can* write:
Move(Ptr^, X, sizeof(X));
becaus
I can't understand what you are trying to say. An array is a pointer
to where the elements of the array resides in memory. How else do you
think it works?
just look at:
type ArrayType = array[1..10] of char;
var X : ArrayType;
PX : ^ArrayType
What is the difference between X and PX?
Also, it is very important to make distinction between static and
dynamic arrays. For static arrays, compiler knows their exact memory
location at compile time (modulo situations where static array is part
of another structure), but for dynamic arrays, compiler only knows
where in memory is refere
You can use include files
On Sat 10 Oct 2009, fpcl...@silvermono.co.za wrote:
> Hi,
>
> According to the note in chapter 2, section 2.2.1 of the FPC
Programmer's
> Guide, it is not possible for conditionals to be exported to other
units.
>
> Is there a way around this?
>
> My Ref:
> Program
2009/10/10 Jürgen Hestermann :
>> I can't understand what you are trying to say. An array is a pointer
>> to where the elements of the array resides in memory. How else do you
>> think it works?
>
> just look at:
>
> type ArrayType = array[1..10] of char;
> var X : ArrayType;
> PX : ^ArrayT
1. Is there a way to get the highest and lowest real values? I can do
high(longint) but high(real) gives me an error. Also of interest is a
low(real) value (-m * 10^n) as distinct from the smallest real value
(m * 10^-n)
2. For the purposes of reserving memory in block sizes that can be
easily
2. For the purposes of reserving memory in block sizes that can be
easily reallocated, I like to use powers of two. So if I have, e.g., a
dynamic array, I might start with a size of 1024 and then double it
when it hits capacity. Hopefully this smoothes memory management, as I
am using a lot
On Sat, 2009-10-10 at 10:14 -0700, David Emerson wrote:
> 2. For the purposes of reserving memory in block sizes that can be
> easily reallocated, I like to use powers of two. So if I have, e.g., a
> dynamic array, I might start with a size of 1024 and then double it
> when it hits capacity. Hop
Henry Vermaak
> I can't understand what you are trying to say. An array is a pointer
> to where the elements of the array resides in memory.
No, not in Pascal. In Pascal an array is a variable just like any other: A name
for some memory area where values can be stored.
> How else do you think
Henry Vermaak :
> One thing I think you don't understand is that an array _is_ a
> pointer. Look at this table to visualise:
>
> http://en.wikipedia.org/wiki/C_syntax#Accessing_elements
One thing I think you don't understand is that arrays and pointers are
orthogonal concepts in almost every o
In our previous episode, "Vinzent H?fler" said:
> > One thing I think you don't understand is that an array _is_ a
> > pointer. Look at this table to visualise:
> >
> > http://en.wikipedia.org/wiki/C_syntax#Accessing_elements
>
> One thing I think you don't understand is that arrays and pointers
2009/10/10 "Vinzent Höfler" :
> Henry Vermaak
>
>> I can't understand what you are trying to say. An array is a pointer
>> to where the elements of the array resides in memory.
>
> No, not in Pascal. In Pascal an array is a variable just like any other: A
> name for some memory area where values
In our previous episode, Henry Vermaak said:
> > and access the record members respectively. It's a static address, known at
> > compile time. No dereferencing.
> >
> >> No, it's not weakened by C-style all of a sudden, it's _always_ been
> >> like this.
> >
> > No. Your confusing arrays and point
2009/10/10 "Vinzent Höfler" :
> Henry Vermaak :
>
>> One thing I think you don't understand is that an array _is_ a
>> pointer. Look at this table to visualise:
>>
>> http://en.wikipedia.org/wiki/C_syntax#Accessing_elements
>
> One thing I think you don't understand is that arrays and pointers are
On Sat, Oct 10, 2009 at 7:14 PM, David Emerson wrote:
> 1. Is there a way to get the highest and lowest real values? I can do
> high(longint) but high(real) gives me an error. Also of interest is a
> low(real) value (-m * 10^n) as distinct from the smallest real value
> (m * 10^-n)
As stated in t
On Sat, Oct 10, 2009 at 20:58, Matthias K. wrote:
> On Sat, Oct 10, 2009 at 7:14 PM, David Emerson wrote:
>> 2. For the purposes of reserving memory in block sizes that can be
>> easily reallocated, I like to use powers of two. So if I have, e.g., a
>> dynamic array, I might start with a size of
On Sat, Oct 10, 2009 at 9:09 PM, Aleksa Todorovic wrote:
> On Sat, Oct 10, 2009 at 20:58, Matthias K. wrote:
>> On Sat, Oct 10, 2009 at 7:14 PM, David Emerson wrote:
>>> 2. For the purposes of reserving memory in block sizes that can be
>>> easily reallocated, I like to use powers of two. So if
Hello!
Because PIC-Support is broken in FPC 2.2.4, I cannot build shared libraries
at time. ( See http://bugs.freepascal.org/view.php?id=12492 )
Unfortunately it is not possible for me to switch to the development
version of FPC, FPC 2.3.0.
So, is there a patch for FPC 2.2.4 available to fix PIC? W
In our previous episode, Matthias Klumpp said:
> Because PIC-Support is broken in FPC 2.2.4, I cannot build shared libraries
> at time. ( See http://bugs.freepascal.org/view.php?id=12492 )
> Unfortunately it is not possible for me to switch to the development
> version of FPC, FPC 2.3.0.
> So, is
On Sat, 10 Oct 2009 23:32:58 +0200 (CEST), mar...@stack.nl (Marco van de
Voort) wrote:
> In our previous episode, Matthias Klumpp said:
>> Because PIC-Support is broken in FPC 2.2.4, I cannot build shared
>> libraries
>> at time. ( See http://bugs.freepascal.org/view.php?id=12492 )
>> Unfortunately
Thanks, guys!
hrm, I am a little disappointed to realize that, although I'm on a
32-bit system, 'real' maps to 'double' rather than 'single' ... and it
is a bit slower, too. So I guess I'll use single for now.
an fpc bsr function would be nice, but I'm gonna stick with compatible
code.
I do r
36 matches
Mail list logo