Re: [fpc-pascal] 64-bit ARM and CPUARM

2024-05-21 Thread Christo Crause via fpc-pascal
On Tue, May 21, 2024 at 10:37 AM Ched via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> In https://www.freepascal.org/docs-html/prog/progap7.html , there is
> specified that
> CPUARM  Free Pascal target is an ARM 32-bit processor.
>
> What about ARM 64-bit processors like the ones in Raspberries ?
> Something similar to CPUPOWERPC with two subcatagories CPUPOWERPC32 and
> CPUPOWERPC64 ?
>
>
ARM-64 is called aarch64 in FPC, so the define should be something like
CPUAARCH64
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Forking the GitLab FPC Source repository

2023-05-01 Thread Christo Crause via fpc-pascal
On Mon, May 1, 2023 at 4:24 PM Norman Dunbar via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> On 30/04/2023 16:59, Michael Van Canneyt via fpc-pascal wrote:
>
> > The repo is not private.
> Ok, thanks. my assumption was obviously incorrect then.
>
>
> > One possible reason is that the repo is simply too big: it has 26 years
> of
> > commits.
> >
> > We had serious problems importing it for this very reason.
> Again, thanks. I'll attempt a different method.
>

FWIW, there are currently 68 forks of the FPC source repository on GitLab.
I forked the repository shortly after it was created, at the time there
were no issues.  I do not expect the size of the repository to be a problem
when creating a fork, there is probably some GitLab related issue.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] IRC channel for FreePascal support ?

2023-04-13 Thread Christo Crause via fpc-pascal
On Thu, Apr 13, 2023 at 11:39 AM Tomas Hajny via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> On 2023-04-13 11:23, Jacob Kroon via fpc-pascal wrote:
>
>
> Hi Jacob,
>
>   .
>   .
> > Ok, maybe this "Joanna" is on this mailing list and would care to
> > elaborate more why I got banned ?
> >
> > The same "Joanna" also kicked me out of the channel a couple of days
> > ago with the reason that "we don't allow lurkers", since I was
> > inactive in the chat.
>
> Just FYI - I don't see anybody having name "Joanna" among people
> subscribed to this mailing list, and nobody like that has been
> considerably active here in the last years as far as my memory serves
> correctly. Obviously, the address and/or name may be completely
> different from the IRC nickname, thus it doesn't mean that you wouldn't
> get the response here for sure. I can't check the list of people
> subscribed to FPC forum, the person may be active there.
>
> Tomas
> (one of FPC mailing list moderators)
>

Most probably user Joanna on the Lazarus/FPC forum:
https://forum.lazarus.freepascal.org/index.php?action=profile;area=summary;u=64282
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-05 Thread Christo Crause via fpc-pascal
On Wed, Apr 5, 2023 at 12:43 PM Bo Berglund via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> On Wed, 5 Apr 2023 11:40:09 +0200, Christo Crause via fpc-pascal
>  wrote:
> >Looking at the datasheet for CAT24C128, Fig. 6 Byte Write Sequence, shows
> >no repeated start condition between register address and data bytes. I
> >suspect that the second i2c message should contain the I2C_M_NOSTART flag,
> >else the address and data parts of the transaction will be separated by a
> >repeated start signal. I have modified the WriteBytesToReg methods in
> >i2c.pas, please feel free to pull from Github and test this again.
>

I tested the i2c code with a PCA9685 IC.  It also supports multi-byte
writes, although it only has 8 bit register addresses.  I realised that my
original code used two i2c transactions and that each transaction starts
with sending the device address.  The multibyte write obviously doesn't
work like this, so I changed the WriteBytesToReg methods (in i2c.pas) to
combine the register address and data into one buffer, which is then
transmitted using the WriteBytes method.

This was tested and confirmed when writing 4 bytes to sequential registers
to a PCA9685 IC with the new WriteBytesToReg method (
https://github.com/ccrause/rpiplc_pas/blob/dc568bbfba2cda50f7ba394469480109e652247d/native/pwm_pca9685.pas#L227
).

Only the WriteBytesToReg for 16 bit register addresses are now untested,
although it follows a similar pattern so I have a reasonable expectation
that it should work.

If this update still doesn't work, I will need a logic analyser trace of an
i2c write transaction that is successful (say using i2ctrace) and one which
is unsuccessful using TI2cMaster.WriteBytesToReg.  Or I need to find a
similar EEPROM to test...

Thanks, I did so and used it in my code but it still does not write the
> EEPROM...
>
> Here is the code I use to test (in a command line program), maybe you can
> see a
> usage problem?
>
> var
>   i2cbus,
>   dev_addr,
>   reg_addr,
>   data_cnt: integer;
>   indata: TBytes;
>
> procedure main_12c_write(); //This is the main application procedure
> var
>   i: integer;
>   num: uint16;
>   i2cEeprom: TI2c_eeprom;
> begin
>   processInputs; //Read command line and write to variables
>   //Now process the data towards the EEPROM
>   i2cEeprom := TI2c_eeprom.Create; //Defaults are set for my EEPROM
>   try
> num := i2cEeprom.WriteData(reg_addr, data_cnt, indata);
> Writeln('Wrote ' + IntToStr(num) + ' bytes to address $' +
> IntToHex(reg_addr,4) );
>   finally
> i2cEeprom.Free;
>   end;
>
> function TI2c_eeprom.WriteData(StartAddress, NumBytes: uint16; Source:
> TBytes):
> uint16;
> var
>   endpos, capacity, addr: uint16;
>   i2cMaster: TI2cMaster;
>   i2cbus: TI2CBus;
>   sourcelen, i, j: integer;
>   pSource: PByte;
> begin
>   Result := 0;
>   //Check valid indata:
>   //snip
>   //Prepare the handler for action...
>   i2cbus := TI2CBus(FI2cBusNo);
>   i2cMaster := TI2cMaster.Create;
>   try
> if not i2cMaster.Initialize(i2cbus) then
> begin
>   writeln('Error opening i2c device: ', FI2cBusNo);
>   exit;
> end;
>
> //Check if data will fit into a single page start at given address:
> if ((StartAddress and $ffc0) = (endpos and  $ffc0)) then //Fits in page
> begin
>   //Perform a single write cycle into the buffer
>   pSource := @source[0];
>   if not i2cMaster.WriteBytesToReg(FEEPROMAddr, startaddress, pSource,
> NumBytes) then
>   begin
> Writeln('Error: Could not write to I2C device!');
> exit;
>   end
>   else
> Result := NumBytes;
> end
> else  //We need to split data over several commands
> begin
>   Writeln('Not yet implmented data split into several writes');
> end;
>   finally
> i2cMaster.Free;
>   end;
>

The use of WriteBytesToReg in the TI2c_eeprom.WriteData method seems fine,
perhaps retest with the updated WriteBytesToReg method.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-05 Thread Christo Crause via fpc-pascal
On Wed, Apr 5, 2023 at 11:22 AM Jean SUZINEAU via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> May be you could get the source code of i2ctransfer from i2c-tools and
> compare it with the code in i2c.pas ?
>

Good idea, that led to the suggestion to try the WriteBytes method which is
similar to how i2ctransfer constructed the i2c transaction.  Hopefully the
change to the WriteBytesToReg methods also fixes the original problem,
since it is a little bit more convenient to work with.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-05 Thread Christo Crause via fpc-pascal
On Wed, Apr 5, 2023 at 7:55 AM Bo Berglund via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> On Wed, 05 Apr 2023 00:33:50 +0200, Bo Berglund via fpc-pascal
>
> I *can* write a sequence of bytes into the EEPROM succsessfully using an
> i2c-tools command like this:
>
> i2ctransfer -y 1 w18@0x50 0x00 0x38 0x00 0x01 0x02 0x03 0x04 0x05 0x06
> 0x07 0x08
> 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f
>
> This writes data starting towards the end of the page and wraps around
> such that
> part of the data gets to the start of the page.
>

Looking at the i2ctransmit transaction data:
$ i2ctransfer 1 w18@0x50 0x00 0x38 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07
0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will send the following messages to device file /dev/i2c-1:
msg 0: addr 0x50, write, len 18, buf 0x00 0x38 0x00 0x01 0x02 0x03 0x04
0x05 0x06 0x07 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f

This can be simulated by calling the WriteBytes method, see new example:
https://github.com/ccrause/rpiplc_pas/blob/main/native/examples/i2c_write_test.lpr

It shows:
> - It is possible to write the data in one go
> - If the data length is past the end of the page it wraps around to the
> beginning
>
> So if the problem cannot be solved then I could either use the loop with
> delay
> or call the i2c-tools command i2ctransfer as a TProcess execution to write
> multiple bytes in one command.
>
> But I would rather not use the TProcess method at all since it relies on an
> external tool being present and the argument list can be pretty long and
> tedious
> to build...
>

Looking at the datasheet for CAT24C128, Fig. 6 Byte Write Sequence, shows
no repeated start condition between register address and data bytes. I
suspect that the second i2c message should contain the I2C_M_NOSTART flag,
else the address and data parts of the transaction will be separated by a
repeated start signal. I have modified the WriteBytesToReg methods in
i2c.pas, please feel free to pull from Github and test this again.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-04 Thread Christo Crause via fpc-pascal
See comments below.

On Tue, Apr 4, 2023 at 6:52 PM Bo Berglund via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> I use the method:
>
> i2cMaster.WriteBytesToReg(i2caddress: byte; regAddress: uint16; data:
> PByte;
> size: byte): boolean;)
>
> With data specified as follows in the call:
>
> if not i2cMaster.WriteBytesToReg(FEEPROMAddr, startaddress, @source[0],
> NumBytes) then
>
> Here the source argument is a TBytes array of bytes so I supply the
> address of
> element 0 as the data argument (expected to be a PByte).
>

This is the correct way of passing the starting address of your data
buffer.  Is your startaddress variable an unsigned 16 bit integer
(word/uint16)? If not, type cast this to a uint16 to ensure the compiler
calls the correct overloaded method.


> When I step through this in the debugger and get into the method itself I
> can
> see that the source argument contains the data I have loaded into it, so
> the
> data is there.
>
> When I run that method to the end and it finishes without error, I still
> cannot
> see the data in the EEPROM at the given address.
>
> So for testing I changed the call to be:
> if not i2cMaster.WriteByteToReg(FEEPROMAddr, startaddress, source[0]) then
>
> This uses the method to write a single byte to the i2c device and it works
> just
> fine!
>
> So either there is a problem with the WriteBytesToReg() method or else my
> use of
> it...
>

Note that I haven't tested WriteByteToReg with a device supporting 10 bit
register addresses, or in your case 16 bit...


> What comes to mind is the data type PByte, which I have never used before
> and do
> not know if it is valid.
>

PByte is a pointer to a byte.


> I am keeping the data in a dynamic array of bytes (the pascal type TBytes)
> and
> send the address of element 0 of that array as the argument to the method.
> Is this wrong?
>

Passing the address of the first element of a TBytes array as you did above
is correct.

If so what should I use instead?
> Can I typecast it like this:
>
> if not i2cMaster.WriteBytesToReg(FEEPROMAddr, startaddress, PByte(source),
> NumBytes) then
> (Tried it and it does not work)
>

No, this does not take the address of source, which is waht is required.


> 
>
> Seems like I am getting close but missing something important...
>

I will look at the EEPROM datasheet, in case the details do not agree with
the WriteBytesToReg implementation.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-02 Thread Christo Crause via fpc-pascal
On Sun, Apr 2, 2023 at 9:30 PM Bo Berglund via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> Is there a reason that there is no i2c_write_reg demo in the github
> package?
>

I haven't gotten round to that, waiting for hardware to test the code with.

I will try to write one so I can test that as well...
>
Would be nice if you could share that :-)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-01 Thread Christo Crause via fpc-pascal
On Sat, Apr 1, 2023 at 9:57 PM Bo Berglund via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> Question:
> Can I use Linux file system commands to read/write the data on the i2c
> EEPROM
> memory device and if so how from fpc?
>

To some extent it is possible to handle i2c transactions as file read/write
operations, but some ioctl calls are required to configure e.g. the device
address [1]. Take note that only a subset of i2c functionality is available
using read/write calls. Lazi2cdev [2] uses this approach.

For finer control over the i2c transactions (for example combined
write/read transactions) low level ioctl calls are available in Linux.  I
wrote an i2c class [3] using this approach.

1. https://www.kernel.org/doc/html/latest/i2c/dev-interface.html
2. https://github.com/laz2wiringpi/lazI2cdev/blob/master/i2cdev_base.pas
2. https://github.com/ccrause/rpiplc_pas/blob/main/native/i2c.pas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Working on a new way to educate people about pascal

2022-12-27 Thread Christo Crause via fpc-pascal
On Tue, Dec 27, 2022 at 6:47 PM Anthony Walter via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> My idea is to implement a web page system where syntax highlight code is
> presented like in the Lazarus IDE, and special links are peppered through
> and explanation of how and why Pascal works by using some example programs.
> When the user highlights the special link, the relevant source code is
> highlighted in the syntax window. This then hopefully allows people to
> understand a bit more about pascal by pairing the explanations with lines
> of source code.
>
> Let me know if you think this approach has any merit or if you think my
> guide could be altered to be a bit more clean in places. As a reminder,
> this page is a wiki, so you cna submit edits to me by clicking the edit
> link at the top of the page. I am able to see and merge your edits.
>

I like the concept implemented in this guide.  A small problem I noticed is
when the source code snippet linked to is not visible, clicking the link
does not move the code snippet into view. This is obviously a tricky
situation since moving the code into view may require shifting the rest of
the document, which may not be desirable.

Explaining the layout and structure of a Pascal program using an example is
a good idea. However, the example topic is quite advanced so a
non-programmer would probably be completely lost regarding the purpose of
the code itself.  Programmers from other languages may also not understand
the concept of a form or the Application instance.  As suggested, perhaps
the example itself should be simple enough so that a non-programmer can
understand the intention of the code.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] [Question] How to submit our patch?

2022-10-10 Thread Christo Crause via fpc-pascal
On Mon, Oct 10, 2022 at 11:47 AM Jinyang He via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> We, a team working for Loongson, are ready to submit some patches which
> support a new architecture named LoongArch for FreePascal. [1] is one of
> repositories about LoongArch. LoongArch is a RISC architecture. The work
> of Loongson was based on MIPS in the past. So LoongArch is somewhat
> similar to MIPS. Of course, there are also commonalities with other RISC
> architectures such as aarch64, riscv, etc. Patches that support LoongArch
> also refer to many other architectures. I have to show my respect to the
> others who contributed FreePascal.
>
> Which way can we submit these patches? I guess we should create a
> 'merge requests' in Gitlab. Is it correct? I hope to find some official
> documentation, or some discussion from the list. All answers are
> needed. Thanks.
>
> [1] https://github.com/loongson


Thank you for offering patches to support LoongArch in FPC.

Also send this message to the FPC developers' mailing list (
fpc-de...@lists.freepascal.org), not all the compiler developers may be
monitoring this list.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] SerReadTimeout question

2022-09-19 Thread Christo Crause via fpc-pascal
On Mon, Sep 19, 2022 at 7:51 AM Christo Crause 
wrote:

>
>
> On Mon, 19 Sep 2022, 03:18 James Richters via fpc-pascal, <
> fpc-pascal@lists.freepascal.org> wrote:
>
>> I can't seem to find any documentation or SerRead or SerReadTimeout..
>> searching for either along with Freepascal doesn't get me any results.
>> If it exists somewhere and I am just missing it, can someone tell me where
>> it is?
>>
>> Anyway, what I'm trying to figure out is when the timeout timer starts...
>>
>
> FPC uses the OS provided functionality to interact with the serial port.
> On Windows the timeout seems to start when the read request is made (
> https://learn.microsoft.com/en-us/previous-versions/ff547486(v=vs.85)).
> On POSIX (at least Linux) it depends on the specific set of flags specified
> , scroll down to the discussion on canonical/noncanonical mode for the
> details (https://linux.die.net/man/3/termios).
>

A bit more information after peeking into the source code: on win32 the
timeout information can be read or set using Get/SetCommTimeouts. The
COMMTIMEOUTS structure (
https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-commtimeouts)
contains a read interval timeout and total timeouts for read & write
operations. SerReadTimeout sets the ReadTotalTimeoutConstant value, so
basically the total timeout duration.

On Linux SerReadTimeout uses a fpSelect on the handle with the specified
timeout, so in principle it is the same behaviour as on Windows, i.e. a
total timeout.

While both OSs provide some functionality to specify inter character
timeouts, FPC does not directly expose this functionality in the Serial
unit.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] SerReadTimeout question

2022-09-18 Thread Christo Crause via fpc-pascal
On Mon, 19 Sep 2022, 03:18 James Richters via fpc-pascal, <
fpc-pascal@lists.freepascal.org> wrote:

> I can't seem to find any documentation or SerRead or SerReadTimeout..
> searching for either along with Freepascal doesn't get me any results.
> If it exists somewhere and I am just missing it, can someone tell me where
> it is?
>
> Anyway, what I'm trying to figure out is when the timeout timer starts...
>

FPC uses the OS provided functionality to interact with the serial port. On
Windows the timeout seems to start when the read request is made (
https://learn.microsoft.com/en-us/previous-versions/ff547486(v=vs.85)). On
POSIX (at least Linux) it depends on the specific set of flags specified ,
scroll down to the discussion on canonical/noncanonical mode for the
details (https://linux.die.net/man/3/termios).

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Test Free Pascal program not compiling

2022-09-11 Thread Christo Crause via fpc-pascal
On Mon, 12 Sep 2022, 02:59 Terry A. Haimann via fpc-pascal, <
fpc-pascal@lists.freepascal.org> wrote:

> Trying to compile a small test pascal program on a arm cpu.  I beleive
> it is an a53.  Libre Le Potato
>
> I am getting the following error:
>
> Error: Error while assembling exitcode 1
>
> Thanks in advance,
>
> Terry H.
>

Enable the compiler's verbose mode (-va). The real error is sometimes
printed much earlier in the compiler output.

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC Backtrace

2022-01-03 Thread Christo Crause via fpc-pascal
On Mon, Jan 3, 2022 at 3:28 PM James Richters via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> I’m curious if there is some way, perhaps with some directive or something
> to force a debug backtrace to happen, but without an error
>

Try calling Dump_Stack in your code:
https://freepascal.org/docs-html/rtl/system/dump_stack.html
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Keeping current with FPC Source on gitlab

2021-11-06 Thread Christo Crause via fpc-pascal
On Sat, 6 Nov 2021, 02:09 James Richters via fpc-pascal, <
fpc-pascal@lists.freepascal.org> wrote:

> Do I need to use the source to re-install FPC every time I want to update
> it?  If so how is this accomplished?
>
> Or is there a better way to just update everything when I update the
> repository without re-installing it?
>

To build the compiler, rtl and packages from newly updated source, call
make clean all

from the base folder of the source containing the compiler, rtl etc
folders. This will produce a new compiler located in the compiler folder.
It will be called something like ppcx64 (depends on your host
architecture).  Compiled units for rtl are located in rtl/units/$fpctarget
and packages will sit under packages/*/units/$fpctarget.

a) You can use this as is without installing, but then your config file
needs to be updated with the relevant locations to units and utilities.
Either call ppcx64 (or your target compiler) directly, or build the fpc
frontend located in compiler/utils, then copy the resulting fpc executable
into the compiler folder from where it can call the target specific
executables.  Since this folder layout is most likely different from the
installed layout, use a different fpc.cfg file with paths updated according
to the source structure.

b) You can install the new compiler (make install), which would typically
overwrite the existing installed version.  Or you can install to a custom
location by specifying INSTALL_PREFIX=path/to/install/folder.  You need the
previous stable compiler to start the build process, so do not overwrite
the installed version.  This also requires a custom fpc.cfg, since the base
folder will be different to the installed path.

For either of the options, call the compiler with the option -n to not load
the default config file (which would point to the installed version,
leading to unit version conflicts) and @/path/to/new/fpc.cfg so that the
compiler can load the new config.

Notes
1. I'm using Linux conventions above, translate path separators and .exe
extensions as required for Windows.
2. If the stable compiler is not in the path, add
FPC=path/to/compiler/ppcx64 to the make commands.
3. There are many more permutations I'm sure, these are just the options
I've managed to get working.

As Ryan mentioned, you have to frequently (if you want to stay up to date)
update the source (git pull), then rebuild.  So configuring your setup
initially is key, after that it is relatively simple to stay up to date.

On a personal note, I got tangled up with config files and conflicts
between old and new compiler versions in the past. When you run into
strange compiler errors about not finding units, or invalid PPU versions or
some such, take note of the paths used for the compiler, config file and
the relevant units.  My strategy was to never install fpc into the search
path, always specify the path to the compiler executable and know when the
compiler should ignore the default and load a specific config file for the
particular compiler.

Alternatively use fpcupdeluxe, it has an option to checkout and build
main.  I haven't tested this much, since I'm comfortable with my workflow.
There is an active thread on the Lazarus forum for fpcupdeluxe support.

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Conversion from C to Pascal - Left bit shift

2021-09-03 Thread Christo Crause via fpc-pascal
On Fri, Sep 3, 2021 at 8:02 AM LacaK via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> Can we say that in Pascal the result of:
>E1 shl E2
> is of same type as E1 ?
> (so if E1 is LongWord then result is LongWord also?)
>
> What if there is an expression on left side:
>(E1*x) shl E2
> Will E1*x promote to 64 bits (on 64 bit target)?
>

See documentation on automatic type conversion (the remarks section below
table 3.3): https://www.freepascal.org/docs-html/ref/refsu4.html#x26-26004r3
While this doesn't explicitly mention shift behaviour, it implies that E1
and (E1*x) will be promoted to native sized integer if smaller.  For the
first example, if E1 is a longword on a 32 bit machine, the result should
also be a longword.

Personal note:  I find the naming of ordinal types confusing.  Is shortint
smaller than smallint, or smallint shorter than shortint? In FPC a word is
2 bytes in size, however on the hardware side a word refers to "the natural
unit of data used by a particular processor design" (
https://en.wikipedia.org/wiki/Word_(computer_architecture)).  I prefer to
use the type aliases with explicit mention of size, such as int16, uint8
etc. I assume the flip side of this is when trying to write portable code
that uses the most efficient size available on a target.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get fpc and lazarus sources when svn has shut down?

2021-08-12 Thread Christo Crause via fpc-pascal
On Thu, Aug 12, 2021 at 7:34 AM LacaK via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

>
> I have related question: in SVN was possible to checkout specific
> sub-directory (for example if I am interested in fcl-db package only I
> checkedout only this sub-directory).
> Is it possible with gitlab? Or I must clone whole
> https://gitlab.com/freepascal.org/fpc/source ?
>

There is a relatively new git feature "sparse-checkout" that could
potentially be used in this case (I haven't tested this).  See e.g.
https://stackoverflow.com/a/60729017/13781629
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get fpc and lazarus sources when svn has shut down?

2021-08-12 Thread Christo Crause via fpc-pascal
On Thu, Aug 12, 2021 at 12:50 AM Bo Berglund via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> On Wed, 11 Aug 2021 22:22:54 +0200 (CEST), Michael Van Canneyt via
> fpc-pascal
>  wrote:
>
> ># Get sources
> >git clone https://gitlab.com/freepascal.org/fpc/source.git  $FPCVER
> ># switch to branch/tag
> >cd $FPCVER
> >git checkout $FPCTAG
> >cd ..
>
> How big a size is the git clone going to pull?
>
> By the looks of it I get the impression that the git clone will download
> every
> single tag/branch/commit etc ever done and then the git checkout activates
> the
> actual tagged file set?
> If this is correct then the size on disk will be too big.
>
> Now as I said I have not used git and for my day use cannot switch because
> we
> use properties of svn that are simply not available in git...
>

To retrieve a specific branch without history (I think this is
approximately equivalent to the svn co command) specify options --branch
(to specify which branch to check out),  --single-branch (to not pull in
other branches) and --depth (to limit the history that git pulls in):

git clone --depth=1 --branch fixes_3_2 --single-branch
https://gitlab.com/freepascal.org/fpc/source.git fpc-fixes_3_2

This example downloads about 46 MiB of data, which expands to around 309
MiB on disk, of which 50 MiB is git information.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Interruption handling on i8086

2021-04-10 Thread Christo Crause via fpc-pascal
On Sat, Apr 10, 2021 at 10:14 AM Guillermo via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> Hi pascaloids,
>
> I'm doing DOS development for fun and, after installing the compiler
> (was quite hard), I'm having problems handling interrupts.
>
> I started with keyboard and it doesn't work.  The handler declaration:
>
>   procedure DOS_KbdHandler; interrupt;
>
> but compiler says:
>
>   keybrd.inc(14,29) Warning: Calling convention directive ignored:
>   "OldFPCCall"
>

This was fixed in trunk rev 39838 (
https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/compiler/pdecsub.pas?r1=39703=39838),
but so far the fix didn't make it into a release yet.  At least for AVR the
warning can be ignored. Not sure why your code doesn't work properly on
i8086 though.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Questions from Semi-Beginner

2021-02-20 Thread Christo Crause via fpc-pascal
On Sat, Feb 20, 2021 at 10:48 AM CSlemaker via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> Title:  OS Upgrade Windows 7 to Windows 10 – Free Pascal Consequences ?
>
> I am currently running under Windows 7 but I MUST upgrade to Windows 10
> Pro.
> 
> Will I need to recompile my Pascal source files for object compatibility
> with Win 10?
> Should I install the latest version of Free Pascal, and if so, which
> version is that?
> Will I have any compatibility problems with my source codes and an
> up-to-date compiler?
>

The change in Windows version should in principle (yes, famous last words)
not impact on your legacy code.  There may be edge cases where permission
levels may change and prevent code from running.  That said I don't program
much on Windows.

Perhaps a bigger factor will be the changes in compiler behaviour. The
compiler team is serious about maintaining backwards compatibility, but
there are some breaking changes (not much really), see the following links:
https://wiki.freepascal.org/User_Changes_3.0
https://wiki.freepascal.org/User_Changes_3.2.0


> 
> P.S. - "Lazarus" is a term I'm not familiar with.  Is it a completely new
> IDE for Free
>Pascal?  Is there a document which describes differences with the old
> IDE?
>Is the old IDE still available in case I have trouble with Lazarus?
>

Lazarus is an independent IDE forFPC that has a graphical interface (a
Delphi IDE clone, somewhat similar to Visual Studio), perhaps a richer
feature set compared to FP and a visual form editor for visual editing of
graphical forms ("windows").  You can install and test it in parallel to
the old FP IDE, there isn't any interaction.  If you don't like Lazarus you
can continue working in FP. A couple of screen shots of Lazarus:
https://wiki.lazarus.freepascal.org/Screenshots
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Value:x:y syntax

2021-02-09 Thread Christo Crause via fpc-pascal
On Tue, Feb 9, 2021 at 2:11 PM Luis Henrique via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> At
> https://lists.freepascal.org/pipermail/fpc-devel/2021-February/043569.html
> I saw the syntax "value: x: y".
> > str(value:6:3, valuestr);
> What is the name of this and where is it documented?
> I did tests and saw that Y determines the width of the precision part, but
> I can't see any effect of X.
>

I guess one can call it optional formatting specifiers.  See documentation:
https://www.freepascal.org/docs-html/rtl/system/str.html
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] basic question on begin, end;

2020-09-23 Thread Christo Crause via fpc-pascal
On Wed, Sep 23, 2020 at 4:25 PM dano none via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> end;
> my_base := my_base + 15;
> writeln('current base ',my_base:2);
> ch := ReadKey;
> {  end;  { end i = column indexer }}
>

A different way to explain Bart's comment is that the inner loop over j is
a compound statement (between the inner loop begin/end block) which is
followed by more statements (the statements after the first end quoted
above).  If you comment out the outer begin/end block these statements are
not included in the execution of the outer loop, so for example my_base is
not incremented as part of the outer loop if the begin/end pair is
commented out as indicated in your example.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug tracker (bugs.freepascal.org) APPLICATION ERROR #400 (db connection failed)

2020-08-30 Thread Christo Crause via fpc-pascal
On Sun, Aug 30, 2020 at 11:26 AM Michael Van Canneyt via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

>
>
> On Sun, 30 Aug 2020, Christo Crause via fpc-pascal wrote:
>
> > On Sun, Aug 30, 2020 at 9:45 AM Dmitry Boyarintsev via fpc-pascal <
> > fpc-pascal@lists.freepascal.org> wrote:
> >
> >> The site opens up with:
> >>
> >> APPLICATION ERROR #400
> >>
> >
> > I also get the above mentioned error when trying to open the website.
>
> The problem should be fixed.
>

I confirm the bug tracker is available again.  Thank you Michael!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug tracker (bugs.freepascal.org) APPLICATION ERROR #400 (db connection failed)

2020-08-30 Thread Christo Crause via fpc-pascal
On Sun, Aug 30, 2020 at 9:45 AM Dmitry Boyarintsev via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> The site opens up with:
>
> APPLICATION ERROR #400
>

I also get the above mentioned error when trying to open the website.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using built-in serial instead of synaser and the like for Linux console app?

2020-08-21 Thread Christo Crause via fpc-pascal
On Fri, Aug 21, 2020 at 12:05 PM Bo Berglund via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> So hence my question:
> Is there something bad about serial (built-in to fpc) that makes it
> unsuitable for use?
>

In my limited experience the FPC serial unit is a bit more low level than
the components such as synaser etc.  There is a bit more of a learning
curve and one needs to decide whether to go blocking or not and how to
handle async reads etc.  I needed to use custom baud rates with auto baud
for an application (debugwire-gdb-bridge) so I took the time to figure out
some of the details.  Since then I've re-used it in other serial based
applications - once you get past the learning curve of how things fit
together it is relatively easy (I guess like most things).  I prefer it now
because it reduces external dependencies in a project.


> Seems like there are virtually no posts describing solutions using
> serial...
>

Here is a unit showing how to open, read and write (blocking) using the
serial unit:
https://github.com/ccrause/debugwire-gdb-bridge/blob/master/serialutils.pas
Unfortunately there is other code for sending a break command and setting
custom baud rates which makes it appear more complicated than it should be.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpDebug function-call proof-of-concept

2020-07-07 Thread Christo Crause via fpc-pascal
On Tue, 7 Jul 2020, 11:17 Joost van der Sluis,  wrote:

> Hi all,
>
> Last weekend I started on the ability to evaluate functions within
> fpDebug. And I got quite far. It is a proof-of-concept, still needs a
> lot of work. But it works!
>

Great news! I guess this is a step towards evaluating object properties via
get methods?

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-13 Thread Christo Crause via fpc-pascal
On Wed, May 13, 2020 at 9:31 AM Michael Van Canneyt 
wrote:

>
> On Wed, 13 May 2020, Christo Crause via fpc-pascal wrote:
>
> > On Tue, May 12, 2020 at 11:11 PM Noel Duffy via fpc-pascal <
> > fpc-pascal@lists.freepascal.org> wrote:
> >
> >> Sure, I can do that. I will look at creating a patch for this. For your
> >> purposes, do you prefer to have a new bug in the bug tracker opened for
> >> tracking this change?
> >>
> >
> > If your patch is related to an existing open bug report then keep
> updates,
> > discussions etc. under the same report, else the information gets
> > fragmented. A reporter cannot delete his/her own old patches, so just
> > append a version number to a new patch, if the patch completely replace a
> > previous patch, and mention the changes/updates in a comment. In your
> case
> > something like StrToHostAddr6-v2.patch for an updated patch.
>
> That is correct if you want to fix a wrong patch.
>
> But not what you should do for this case, because there are 2
> issues: fix existing api, and extend the existing api (a refactor).
>
> So: separate reports, and if so desired add a link in 'related to'.
>

Apologies, I should probably only comment if I followed all the details of
the discussion...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-13 Thread Christo Crause via fpc-pascal
On Tue, May 12, 2020 at 11:11 PM Noel Duffy via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> Sure, I can do that. I will look at creating a patch for this. For your
> purposes, do you prefer to have a new bug in the bug tracker opened for
> tracking this change?
>

If your patch is related to an existing open bug report then keep updates,
discussions etc. under the same report, else the information gets
fragmented. A reporter cannot delete his/her own old patches, so just
append a version number to a new patch, if the patch completely replace a
previous patch, and mention the changes/updates in a comment. In your case
something like StrToHostAddr6-v2.patch for an updated patch.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Bugs in StrToHostAddr6 in sockets unit

2020-05-06 Thread Christo Crause via fpc-pascal
On Wed, May 6, 2020 at 12:19 PM Noel Duffy via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> So I guess the question is, is it worth the effort to make
> StrToHostAddr6 RFC4291 compliant? Is that something the FPC team would
> want, or do they just not use the sockets unit?
>

There have been 2 changes applied to sockets.inc in the last two months so
it is not neglected.
I am convinced a patch to ensure compliance will be considered for
inclusion, especially if you
provide test cases demonstrating shortcomings in the current implementation.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pascal Language Server

2020-04-23 Thread Christo Crause via fpc-pascal
On Thu, 23 Apr 2020, 21:43 Ryan Joseph via fpc-pascal, <
fpc-pascal@lists.freepascal.org> wrote:

> ok, did this and now getting:
>
> /Users/ryanjoseph/Developer/lazarus/components/lazdebuggergdbmi/gdbmidebugger.pp(63,16)
> Fatal: (10022) Can't find unit PropEdits used by GDBMIDebugger
>
> svn up says "At revision 63051."
>
> Never an easy time building lazarus for me. :)
>
> Regards,
> Ryan Joseph
>

I usually revert to brute force troubleshooting in these instances: pass -
va to the compiler. A lot of information, but usually the problem is close
to the end so scanning the output in reverse should often reveal what is
wrong.

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] About fpc license.

2020-04-09 Thread Christo Crause via fpc-pascal
On Fri, 10 Apr 2020, 05:09 fredvs via fpc-pascal, <
fpc-pascal@lists.freepascal.org> wrote:

> Hello.
>
> I have done a fork of fpc fixes_3_2 and made some modification of original
> code.
>
> May I distribute the fpc binary of that patched version with the units
> files, ready to use out-of-the-box?
>

In my opinion yes,  but note I only represent my own opinion here. On a
practical side, make sure that your users know they are downloading a
custom patched version not supported by the fpc team.


Must I add the source of the change done?
>

As a minimum clearly display a download link to the modified source in the
download. Could be a separate text file in the download, perhaps listing
the modifications and link to the source.

I What I am not allowed to do?
>

Anything not permitted by fpc's licences :)

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to rebuild an fpc package

2020-02-11 Thread Christo Crause via fpc-pascal
On Tue, Feb 11, 2020 at 4:57 PM Luis - SoftSAT Sistemas <
l...@softsatsistemas.com.br> wrote:

> > You are using relative paths in -Fu and your current folder is
> c:\lazarus\fpc\3.0.4\source\packages\fcl-db, so
> > -Fu../../rtl should expand to -Fuc:\lazarus\fpc\3.0.4\source\rtl - the
> compiler is searching where it was told.
> This is done by the make file that come with the package.
>
> > It may be easier to just specify the absolute path to the compiled RTL
> units, for example:
> > -Fuc:\lazarus\fpc\3.0.4\units\rtl\your-target
> If i add this with `make OPT=-Fu` it advances to next error and
> require another unit.
>
> >> C:/lazarus/fpc/3.0.4/bin/i386-win32/ppc386.exe fpmake.pp -n -Fu../../r
> if i edit the make file and remove the "-n" flag it compiles the fpmake
> but when fpmake is run its throws another error.
>
> Anyway, looks like there are some problem with the makefile or with
> something else on my system.
>

I guess the problem is how to tell the make system when to use installed
units and when to recompile units.  Although it should be possible to
figure out how to do this, I rather suggest an easier fix: just recompile
everything with "make all install" from the base of the fpc source folder.
This way the makefiles do all the tracking of where compiled units are.
The few minutes this will take should be much less than the time spent
trying to figure out how to fix your original problem.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to rebuild an fpc package

2020-02-11 Thread Christo Crause via fpc-pascal
On Tue, Feb 11, 2020 at 3:23 PM Luis - SoftSAT Sistemas via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> Looking at unit search path the compiler are looking at "sources" dir
> instead of "units" dir with the compiled units and i dont know how to fix
> this.
>
> C:\lazarus\fpc\3.0.4\source\packages\fcl-db>make all OPT=-vut
> C:/lazarus/fpc/3.0.4/bin/i386-win32/ppc386.exe fpmake.pp -n -Fu../../r
> tl -Fu../../packages/paszlib -Fu../../packages/fcl-process
> -Fu../../packages/has
> h -Fu../../packages/libtar -Fu../../packages/fpmkunit  -vut
>

You are using relative paths in -Fu and your current folder is
c:\lazarus\fpc\3.0.4\source\packages\fcl-db, so
-Fu../../rtl should expand to -Fuc:\lazarus\fpc\3.0.4\source\rtl - the
compiler is searching where it was told.

It may be easier to just specify the absolute path to the compiled RTL
units, for example:
-Fuc:\lazarus\fpc\3.0.4\units\rtl\your-target
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Git mirror

2019-10-29 Thread Christo Crause
On Tue, Oct 29, 2019 at 8:27 AM denisgolovan  wrote:

> Hi all
>
> Looks like Graeme's FPC git mirror stopped syncing with svn.
> I've sent a private mail, but no response.
> Could somebody help?
>

It appears that the last commit on svn was on the 27th (
https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/utils/?sortby=date=log)
which is the same date as the last commit on Graeme's mirror (
https://github.com/graemeg/freepascal/commit/a1fd692f4f98e4889eb9ef333075a6c0f8dd0891).
I thus don't think there is a sync problem.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC RGB+W LEDs

2019-10-24 Thread Christo Crause
A user space library written in C: https://github.com/jgarff/rpi_ws281x

On Thu, Oct 24, 2019 at 3:54 PM James Richters <
ja...@productionautomation.net> wrote:

> I'm thinking about making a controller for SK6812 Individually addressable
> RGB+W Led strips, perhaps something I can run on a Raspberry Pi.  I'm
> curious if anyone has any example routines that do the output timing for
> Individually addressable LED strips?
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] *etFTime -> File*etDate

2019-10-13 Thread Christo Crause
On Sun, Oct 13, 2019 at 8:03 PM Ched <
charles.edouard.des.vastes.vig...@gmail.com> wrote:

> Hello,
>
> In https://www.freepascal.org/docs-html/rtl/sysutils/filenameroutines.html
> ,
>
> FileSetDate <
> https://www.freepascal.org/docs-html/rtl/sysutils/filesetdate.html>Get
> file dates  should be
> corrected to _S_et .
>
I don't see any mix-up of Get and Set on either the FileSetDate or
FileGetDate pages at your link above.


> Now, my real problem is that the following code is compiled when SYS is
> not defined, and isn't when it
> is, and I really don't know why.
>
> PROGRAM QQ;
> { $DEFINE SYS}
> USES
> {$IFDEF SYS}
>SYSUTILS;
> {$ELSE}
>DOS;
> {$ENDIF}
> VAR
> FO: FILE OF DOUBLE;
> L: LONGINT;
> BEGIN
> ASSIGN(FO, 'blabla.bin');
> RESET(FO);
> {$IFDEF SYS}
>L:=FILEGETDATE(FO);   { Got File, expected LongInt }
> {$ELSE}
>GETFTIME(FO, L);
> {$ENDIF}
> CLOSE(FO);
> END.
>

The file variable FO in your code should be declared as type THandle (which
is an alias for LongInt) when you are using the SysUtils file handling
routines.  Take a look at the example at the bottom of FileCreate (
https://www.freepascal.org/docs-html/rtl/sysutils/filecreate.html) to see
how to work with these routines.


> Well, it appears that I prbably haven't fully understand the dos->sysutils
> conversion.
>

You are mixing classic Pascal style file handling (Assign, Reset, Close)
which isn't (AFAIK) Dos style, with an alternative file handling style
defined in SysUtils.

Cheers, Ched'
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Building complier fails in itolitlsreader.pas

2019-10-09 Thread Christo Crause
On Wed, Oct 9, 2019 at 8:04 PM Ryan Joseph  wrote:

> Updated from svn just now (r43157) and tried to build but I get this
> error. Pasted below is the source from itolitlsreader.pas and it appears
> it’s totally mangled. Are other users seeing this also or did my SVN break
> something?
>
> itolitlsreader.pas(385,24) Error: Identifier not found "Sta"
> itolitlsreader.pas(385,48) Fatal: Syntax error, ";" expected but
> "identifier UNKNOWN1" found
> Fatal: Compilation aborted
>
>   while ChunkIndex <> -1 do
>   begin
> Chunk.Position:=0;
> fStream.Position:= Sta unknown1   : dword; //
> always -1
> nrblock: dword; // Number of blocks
> treedepth  : word;  // The depth of the tree
> of blocks (1 if no index blocks, 2 one level of index blocks, ...)
> nrkeywords : dword; // number of keywords in
> the file.
> codepage   : dword; // Windows code page
> identifier (usually 1252 - Windows 3.1 US (ANSI))
> lcid   : dword; // LCID from the HHP file.
> ischm  : dword; // 0 if this a BTREE and
> is part of a CHW file, 1 if it is a BTree and is part of a CHI or CHM file
> unknown2   : dword; // Unknown. Almost always
> 10031. Also 66631 (accessib.chm, ieeula.chm, iesupp.chm, iexplore.chm,
> msoe.chm, mstask.chm, ratings.chm, wab.chm).
> unknown3   : dword; // unknown 0
> unknown4   : dword; // unknown 0
> unknown5   : dword; // unknown 0
>   end;
>   PBTreeBlockHeader = ^TBtreeBlockHeader;
>   TBtreeBlockHeader = packed record
> Length : word;  // Length of free
> space at the end of the block.
> NumberOfEntries: word;  // Number of entries
> in the block.
> IndexOfPrevBlock   : dword; // Index of the
> previous block. -1 if this is the first listing block.
> IndexOfNextBlock   : dword; // Index of the next
> block. -1 if this is the last listing block.
>   end;
>

My guess is you have a corrupted file. According to the SVN info that file
was last changed in 2013.  Viewing the file via the online viewer shows
nothing peculiar around line 385:
https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/chm/src/itolitlsreader.pas?view=markup#l385.
I have also updated via svn (r43158) and that came through good.  It is
busy building but no problems so far.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread Christo Crause
On Wed, Sep 11, 2019 at 7:06 AM Ralf Quint  wrote:

> On 9/10/2019 4:26 PM, wkitt...@windstream.net wrote:
> > On 9/9/19 10:11 AM, James Richters wrote:
> >> Pascal doesn't have things like step...
> >
> > hunh??? i don't think that's right but i'm just catching up after
> > several 10+ hours days of $job...
> >
> > i know that i've written code in the past that did use something to
> > step X numbers per run through the look and it did not involved
> > manually incrementing the loop var...
> >
> >
> I am not aware of any Pascal implementation that does have a STEP
> parameter for FOR loops, and I am programming in Pascal at least as long
> as you... ;-)
>

FPC documentation:
https://www.freepascal.org/docs-html/ref/refsu58.html#x164-18600013.2.4 -
at least FPC doesn't allow specifying an increment size.  Several other
languages do allow specifying an increment (nice list of for loop
constructs with specified increment in various languages:
https://www.rosettacode.org/wiki/Loops/For_with_a_specified_step).  Modula-2
or Oberon-2 code snippets could perhaps be mistaken for Pascal through the
mists of time.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compile fpc twice or only once during install?

2019-07-12 Thread Christo Crause
On Fri, 12 Jul 2019, 14:19 Bo Berglund,  wrote:

> When I install FPC/Lazarus on new Linux systems I use a script I wrote
> several years ago. It is cofigured for the actual versions to install
> but otherwise it is self-contained.
>
> What it does concerning fpc is:
> - Get the tagged version of the sources from svn (typically 3.0.4)
> - Get the seed compiler 3.0.0, which I have stored on my website
> - Build all using the seed compiler
> - Install sources etc.
>
> Now I wonder if I should add a second "make all" after pointing to the
> newly built 3.0.4 such that the final result is fpc 3.0.4 built from
> sources compiled by itself?
>
> Or is this superfluous?
>

AFAIK the make file cycle through the compiler build process 3, starting a
new cycle with the compiler from the previous cycle. So no need to make all
a 2nd time, it is implicit in the make file recipe.

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compile for WinCE 7, target ARM, CPU Cortex-A9

2019-04-04 Thread Christo Crause
On Thu, Apr 4, 2019 at 1:13 PM LacaK  wrote:

> Answering my own question:
>
> When I build cross compiler using FpcUpDeluxe, where I set "Cross Build
> Options Override" to "-Cparmv7A" (The Cortex -A9 cores implement the
> ARMv7-A architecture) then I can sucessfully compile my application for
> WinCE 7.
>
> Drawback is that I must now maintain 2 FPC installations/cross-compilers
> (Win32-WinCE): one for targer WinCE 5,6 with CPUs ARMv5 and another for
> WinCE 7 with ARMv7 CPU (It is not sufficient to setup build modes in
> project ... also all units must be pre-compiled ... at least I do not
> know how to bypass this limitation)
>
> -Laco.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


I suspect your problem is related to this feature request:
https://bugs.freepascal.org/view.php?id=30294

Note that you probably don't need two different cross compilers if your
cpu-OS target is the same, only two different versions of the RTL (and
perhaps packages) in a way that enables the compiler to pick the correct
version.  For avr-embedded I change the unit output folder name to
avr-embedded-SUBARCH and add the subarch macro to fpc.cfg.  For arm you may
also need to handle different ABI versions (I don't cross compile for arm).
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Registers used by calling conventions

2019-03-08 Thread Christo Crause
On Sat, Mar 9, 2019 at 12:13 AM Anthony Walter  wrote:

> ... The {$asmmode intel} compiler directive changes the asm syntax of
> what's allowed in your unit, but it does not change how dissasembled code
> is displayed in the Lazarus dissasembler view. I'd like to see instructions
> dissambled in the Lazarus helper window using the Intel style. I wasn't
> referring to the asm code in the source code editor.
>

The disassembly is prepared by the debugger.  For GDB you can set the
disassemble flavour by "set disassemble-flavor intel".  In Lazarus: Tools -
Options, go to Debugger - General then look for property AssemblerStyle and
change to gdasIntel.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] INSTALL_PREFIX, INSTALL_LIBDIR

2018-10-19 Thread Christo Crause
On Fri, 19 Oct 2018, 16:40 christo,  wrote:

> On 2018/10/18 09:26, Mattias Gaertner via fpc-pascal wrote:
> > How to control where 'make install' puts the libraries (e.g.
> > libpas2js.so)?
> >
> > I tried "INSTALL_LIBDIR=~/tmp/lib64", but that moves everything *except*
> > libraries to "~/tmp/lib64".
> >
> > See bug https://bugs.freepascal.org/view.php?id=34346
>
> In trunk (rev. 39838):
>
> "make info FPC=[path to ppcx64]" gives:
>

Hang on, the packages and utilities are installed with fpmake, so one also
has to figure out how fpmake handles the - - prefix and - - baseinstalldir
parameters...

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

Re: [fpc-pascal] INSTALL_PREFIX, INSTALL_LIBDIR

2018-10-19 Thread christo

On 2018/10/18 09:26, Mattias Gaertner via fpc-pascal wrote:

How to control where 'make install' puts the libraries (e.g.
libpas2js.so)?

I tried "INSTALL_LIBDIR=~/tmp/lib64", but that moves everything *except*
libraries to "~/tmp/lib64".

See bug https://bugs.freepascal.org/view.php?id=34346


In trunk (rev. 39838):

"make info FPC=[path to ppcx64]" gives:

Install base dir. /usr/local/lib/fpc/3.3.1
Install binary dir... /usr/local/bin
Install library dir.. /usr/local/lib
Install units dir /usr/local/lib/fpc/3.3.1/units/x86_64-linux/fpc

"make info INSTALL_PREFIX=/xxx FPC=[path to ppcx64]" gives:

Install base dir. /xxx/lib/fpc/3.3.1
Install binary dir... /xxx/bin
Install library dir.. /xxx/lib
Install units dir /xxx/lib/fpc/3.3.1/units/x86_64-linux/fpc

"make info INSTALL_PREFIX=/xxx INSTALL_LIBDIR=/yyy FPC=[path to ppcx64]" 
gives:


Install base dir. /xxx/lib/fpc/3.3.1
Install binary dir... /xxx/bin
Install library dir.. /yyy
Install units dir /xxx/lib/fpc/3.3.1/units/x86_64-linux/fpc

This seems different to your case.  Which version of FPC are you using?

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

Re: [fpc-pascal] Add assembler source file to fpmake package?

2018-10-15 Thread christo

On 15/10/2018 23:56, Sven Barth via fpc-pascal wrote:
christo mailto:christo.cra...@gmail.com>> 
schrieb am Mo., 15. Okt. 2018, 21:41:


On 15/10/2018 20:07, Sven Barth via fpc-pascal wrote:

christo mailto:christo.cra...@gmail.com>> schrieb am Mo., 15. Okt. 2018,
18:22:

I'm trying to build a fpmake project for the RTL. 



Are you aware that the RTL already has a fpmake project? It might
not be entirely up to date, but it exists.


I somehow did not notice the existing fpmake before, it seems
impossible to miss now! Anyway, seems like some more work is still
required to make the existing fpmake usable.  It also doesn't have
support for assembling assembler source files, so my original
question remains.


Did you look at the rtl/linux/fpmake.inc file? It adds the loaders 
there. Though I have not tested it and don't know if it works.


Thanks for the hint Sven, my mistake seems to be creating a new target 
for the loaders.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Add assembler source file to fpmake package?

2018-10-15 Thread christo

On 15/10/2018 20:07, Sven Barth via fpc-pascal wrote:
christo mailto:christo.cra...@gmail.com>> 
schrieb am Mo., 15. Okt. 2018, 18:22:


I'm trying to build a fpmake project for the RTL. 



Are you aware that the RTL already has a fpmake project? It might not 
be entirely up to date, but it exists.


I somehow did not notice the existing fpmake before, it seems impossible 
to miss now! Anyway, seems like some more work is still required to make 
the existing fpmake usable.  It also doesn't have support for assembling 
assembler source files, so my original question remains.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Add assembler source file to fpmake package?

2018-10-15 Thread christo
I'm trying to build a fpmake project for the RTL.  One problem I'm 
struggling with is how to add an assembler file to the package and 
assign a custom command to be executed instead of calling the compiler.  
I've tried the following, which does call "as" but then it follows with 
an error because the compiler gets called with the assembler file which 
then generates an error:


  T := TTarget(P.Targets.Add);
  T.Name := 'linux/'+CPUToString(Defaults.CPU)+'/prt0.as';
  T.CPUs := [x86_64];
  T.OSes := [linux];
  T.Commands.AddCommand('as', '--64 -o ' + 'prt0.o ' + 
'linux/'+CPUToString(Defaults.CPU)+'/prt0.as', 'prt0.o', 'prt0.as');


Looking at the various methods of TTarget (addUnit, addFPDoc, 
addProgram, addImplicitUnit) seems to suggest that functionality for 
adding a generic file and calling an external custom command is lacking.


Any ideas or suggestions on how to get this case working?

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

Re: [fpc-pascal] No breakpoint capability

2018-08-26 Thread Christo
On Sat, 2018-08-25 at 10:56 -0400, john youngquist wrote:
> I updated to FPC 3.0.4 and can't get breakpoints to work.
> 
> I get a "can't set breakpoint message" on all lines.
> 
> I am in debug mode and have "generate debug information" enabled.
> 
> This all worked fine in the previous version. I have searched all the 
> documentation
> 
> I can find and can't even find the word breakpoint. What am I missing?
> 

I assume you are using Lazarus? What do you see in the Debug Output window
when you get the message above?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Will moving from due core CPU to 6 Core CPU of the same clock speed improve the speed of FPC compiling?

2018-08-08 Thread Christo
On Wed, 2018-08-08 at 19:24 +0800, Dennis wrote:
> 
> Christo Crause wrote:
> > 
> > On Tue, Aug 7, 2018 at 9:42 AM, Dennis Poon  wrote:
> > > Only 20 seconds. But sometimes, when I modify some units used by other 
> > > units which are in
> > > turn used by other units, FPC throws the following exception when I 
> > > compile (not build)
> > > uspdata.pas(228,50) Error: Compilation raised exception internally
> > > 
> > > When that happens, I have to build the entire project, and that takes 
> > > much longer.
> > > 
> > Are you perhaps using generics somewhere in your project? If so your 
> > compiler crash may be
> > similar to bugs 0033593, 0034024 and possibly 0034065.
> > 
>  Yes, I use quite a lot of generics of Generics.Collection   TList and 
> TDictionary etc.
> Are these bugs fixed in the trunk version?
All three bug reports are still open, so not fixed yet.  If you can reduce the 
problem to a
small project with dummy code it may help to to file another bug report to 
highlight this
problem in the compiler. ___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Will moving from due core CPU to 6 Core CPU of the same clock speed improve the speed of FPC compiling?

2018-08-08 Thread Christo Crause
On Tue, Aug 7, 2018 at 9:42 AM, Dennis Poon  wrote:

> Only 20 seconds. But sometimes, when I modify some units used by other
> units which are in turn used by other units, FPC throws the following
> exception when I compile (not build)
> uspdata.pas(228,50) Error: Compilation raised exception internally
>
> When that happens, I have to build the entire project, and that takes much
> longer.
>

Are you perhaps using generics somewhere in your project? If so your
compiler crash may be similar to bugs 0033593, 0034024 and possibly 0034065.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Is this the correct way to configure fpc for multiple arm-embedded subarchs?

2018-07-04 Thread Christo
On Thu, 2018-07-05 at 00:20 +0200, Tomas Hajny wrote:
> If you look into fpmake.pp in the same directory, you'll find out that the
> proper command line for calling data2inc should be:
> 
> data2inc -b -s fpcmake.ini fpcmake.inc fpcmakeini
> 
> (add paths as necessary, e.g. the path to data2inc if not on PATH)

Thank you Tomas, I didn't specify the correct options to data2inc.
I managed to regenerate a makefile which reflected the changes in fpcmake.ini!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Is this the correct way to configure fpc for multiple arm-embedded subarchs?

2018-07-04 Thread Christo
On Wed, 2018-07-04 at 11:57 +0200, Tomas Hajny wrote:
> The .ini file should be translated to .inc using the data2inc utility
> (included with FPC as well) and then incorporated into the binary. This
> should happen automatically, but let's make sure it was the case for you
> as well.

The .inc file is not regenerated when running make in the fpcm directory.
At first the data2inc utility couldn't be found, fixed that by specifying
DATA2INC=path/to/data2inc. This still didn't regenerate the .inc file.  Tried 
to generate only the .inc file by calling data2inc manually passing unmodified
fpcmake.ini as input - this resulted in a parsing error:

~/fpc/3.1.1/utils/fpcm $ ../bin/x86_64-linux/data2inc fpcmake.ini fpcmake.inc
processing file : fpcmake.ini
Some error with a \xxx constant or a stale (unescaped) backslash
Error in line : 35 Somewhere near :'OVERR'

Data2inc also gives an error when reading data2inc.exm, which seems strange.
Same error when testing data2inc of 3.0.4 (compiled from source). I've already 
deleted, restored and rebuild the utils directory of trunk but get the same 
error.

This is really strange because data2inc seems like a very mature tool.

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

Re: [fpc-pascal] Is this the correct way to configure fpc for multiple arm-embedded subarchs?

2018-07-04 Thread Christo Crause
On Wed, Jul 4, 2018 at 9:21 AM, Tomas Hajny  wrote:

> On Wed, July 4, 2018 07:53, Christo wrote:
> > Any hints on how to compile and use fpcmake so that changes in the ini
> > file ends up in the generated MakeFile?
>
> I assume that you updated fpcmake.ini in /fpcsrc/utils/fpcm/ (or without
> /fpcsrc if using a checkout of the fpc repository rather than fpcbuild)
> and rebuilt either all utils, or just fpcmake, right? Could you please
> check whether fpcmake.inc (in the same directory) got updated during the
> rebuild (this should reflect your changes to fpcmake.ini)? If I understand
> it correctly, you copied the resulting updated fpcmake binary into the
> respective RTL directory and tried to regenerate the Makefile there,
> correct?


My update procedure is basically what you describe: I manually added the
changes from r30766 fpcmake.ini to trunk, then call make inside the fpcm
directory, then execute the newly compiled fpcmake with the Makefile.fpc
file in the fpcm directory as test.

Tonight I will check if fpcmake.inc got updated.  Thanks for this hint, I
don't
yet know how the different fpcmake pieces fit together.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Is this the correct way to configure fpc for multiple arm-embedded subarchs?

2018-07-03 Thread Christo
On Sun, 2017-12-03 at 19:05 +0100, Florian Klämpfl wrote:
> Am 29.11.2017 um 06:36 schrieb Christo:
> > 
> > On Sun, 2017-11-26 at 17:19 +0100, Michael Ring wrote:
> > > 
> > > I am looking for an easy way to have all cortex-m compilers available
> > > at the same time to be able to do automated building/testing
> > There is a similar problem with the AVR target having several
> > subarchitectures.  One option I think is to have a subarch defined by
> > the compiler, then it would be easy to lay out the compiled unit
> > structure in fpc.cfg according to subarch.  I've made an attempt at
> > adding a subarch define to my local compiler source for AVR, but
> > haven't developed the idea further.  I'm not a compiler dev so there
> > may be better options.

> Subarch directories are imo the best solution, I have a half-backen patch for 
> this, not yet
> finished
> though.

I'm trying to move Florian's changes in the target-subdir branch to trunk. I've 
updated
fpcmake.ini, but when I compile fpcmake and execute ./fpcmake -Tall -w 
Makefile.fpc the
regenerated MakeFile doesn't have any of the modifications in fpcmake.ini.

Any hints on how to compile and use fpcmake so that changes in the ini file 
ends up in the
generated MakeFile? 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Generating RTL Units for STM32 Processors

2018-02-27 Thread Christo Crause
On 28 Feb 2018 4:22 am, "R0b0t1"  wrote:

I will be following up with you off list, since you do not seem to mind.


I'm also interested in the general topic of incorporating embedded
controllers (avr at the moment)  into fpc. It would be useful to me if I
could follow at least the general highlights for the porting process, not
necessarily all the platform specific details.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Is this the correct way to configure fpc for multiple arm-embedded subarchs?

2018-02-22 Thread Christo Crause
Michael, I have just noticed a target-subdir folder in
svn.freepascal.org/svn/fpc/branches/target-subdir/
It seems as if rev 30766 contains Florian's first modifications to
implementation the subarch subfolder option.


On 4 Dec 2017 9:23 am, "Michael Ring"  wrote:

Hi Florian!

I would like to work on this patch, can you share it with me?

Thank you,

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

Re: [fpc-pascal] Is this the correct way to configure fpc for multiple arm-embedded subarchs?

2018-02-22 Thread Christo
On Mon, 2017-12-04 at 08:22 +0100, Michael Ring wrote:
> Hi Florian!
> 
> I would like to work on this patch, can you share it with me?
> 
> Thank you,
> 
> Michael
> 
> 
> Am 03.12.17 um 19:05 schrieb Florian Klämpfl:
> > 
> > Am 29.11.2017 um 06:36 schrieb Christo:
> > > 
> > > On Sun, 2017-11-26 at 17:19 +0100, Michael Ring wrote:
> > > > 
> > > > I am looking for an easy way to have all cortex-m compilers available
> > > > at the same time to be able to do automated building/testing
> > > There is a similar problem with the AVR target having several
> > > subarchitectures.  One option I think is to have a subarch defined by
> > > the compiler, then it would be easy to lay out the compiled unit
> > > structure in fpc.cfg according to subarch.  I've made an attempt at
> > > adding a subarch define to my local compiler source for AVR, but
> > > haven't developed the idea further.  I'm not a compiler dev so there
> > > may be better options.
> > Subarch directories are imo the best solution, I have a half-backen patch 
> > for this, not yet
> > finished
> > though.

I've made a script file (attached) that iterates through the different 
subarchitectures
available for the AVR compiler, calls make and then moves the compiled units to 
a subdirectory.
I think the logic of this script should be moved to the existing rtl makefile 
so that all
subarchitectures for a target gets generated and sorted in one go.  Of course 
then the default
fpc.cfg ideally needs to be updated to reflect the subarch folder structure for 
ARM and AVR.

I'm putting this out there hoping that someone familiar with the topic and 
makefile syntax can
help with a patch for FPC.

build-AVR-embedded-rtl-all.sh
Description: application/shellscript
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Cannot reference macro identifier in assembler code

2018-02-19 Thread Christo
The following code doesn't compile for the AVR target (FPC 38288):

program macrotest;
begin
  asm
  {$ifdef FPC_SRAMSIZE}
sts FPC_SRAMSIZE , r31  // macrotest.pp(5,9) Error: Unknown identifier 
"FPC_SRAMSIZE"
  {$endif}
  end;
end. 

Is the use of macros in assembler blocks allowed?

(Compiled with: ~/fpc/3.1.1/compiler/avr/pp -Wpattiny13 -Sgm macrotest.pp)

Clearly the ifdef check passed so FPC_SRAMSIZE is defined, however when the 
macro is used FPC
doesn't recognize it.  If the macro reference is moved outside the asm block to 
a const then it
works as expected (to some degree, there is another problem unrelated to the 
use of a macro).
This code compiles as expected:

program macrotest;
const
  sramSize = FPC_SRAMSIZE;
begin
  asm
    sts sramSize , r31
  end;
end.

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

Re: [fpc-pascal] Error when trying to make tests for target AVR

2018-01-07 Thread Christo
On Sun, 2018-01-07 at 11:30 +0100, Florian Klaempfl wrote:
> Am 07.01.2018 um 06:12 schrieb Christo:
> > 
> > On Sun, 2018-01-07 at 05:59 +0200, Christo wrote:
> > > 
> > > __missing_command_FPCMAKE -p -Tavr-embedded Makefile.fpc
> > Adding fpc_baseinfo to the make command revealed that FPCMAKE was not 
> > defined (I guess it
> > should
> > have been obvious from the error message in the first place). I added the 
> > path to fpcmake
> > (FPCMAKE=path_to_fpcmake) to the make command line and the tests are now 
> > running.
> Do you have an fpcmake somewhere in your path?

No, I uninstalled fpc and run from compiled source. At some point I had version 
conflicts when
building trunk and now I run everything from the fpc source folder.  The 
downside is that
sometimes utilities aren't where they are expected, like in this case. 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Error when trying to make tests for target AVR

2018-01-06 Thread Christo
On Sun, 2018-01-07 at 05:59 +0200, Christo wrote:
> __missing_command_FPCMAKE -p -Tavr-embedded Makefile.fpc

Adding fpc_baseinfo to the make command revealed that FPCMAKE was not defined 
(I guess it should
have been obvious from the error message in the first place). I added the path 
to fpcmake
(FPCMAKE=path_to_fpcmake) to the make command line and the tests are now 
running.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Error when trying to make tests for target AVR

2018-01-06 Thread Christo
I'm trying to run the test suite for AVR by executing the following make 
statement:

make FPC=~/fpc/3.1.1/compiler/ppcx64 TEST_FPC=~/fpc/3.1.1/compiler/ppcrossavr
TEST_CPU_TARGET=avr TEST_OS_TARGET=embedded TEST_SUBARCH=avr5 TEST_OPT="-XPavr-"

from the /tests folder. Make terminates with the error, see below for the last 
couple of lines of output:
make -C tstunits FPC_VERSION= FPC=/home/christo/fpc/3.1.1/compiler/ppcrossavr 
CPU_TARGET=avr OS_TARGET=embedded SUBARCH=avr5 'OPT=-XPavr- -Fd' CCOMPILER= 
BINUTILSPREFIX=
make[2]: Entering directory '/home/christo/fpc/3.1.1/tests/tstunits'
make -C ../../rtl all 'OPT= -n' 'CROSSOPT=-XPavr- -Fd'
make[3]: Entering directory '/home/christo/fpc/3.1.1/rtl'
make -C embedded all
make[4]: Entering directory '/home/christo/fpc/3.1.1/rtl/embedded'
make[4]: Leaving directory '/home/christo/fpc/3.1.1/rtl/embedded'
make[3]: Leaving directory '/home/christo/fpc/3.1.1/rtl'
make -C ../../rtl install 
INSTALL_PREFIX=/home/christo/fpc/3.1.1/tests/tstunits/tmp 
INSTALL_UNITDIR=/home/christo/fpc/3.1.1/tests/tstunits/avr-embedded OPT= 
CROSSOPT=
make[3]: Entering directory '/home/christo/fpc/3.1.1/rtl'
make -C embedded all
make[4]: Entering directory '/home/christo/fpc/3.1.1/rtl/embedded'
make[4]: Leaving directory '/home/christo/fpc/3.1.1/rtl/embedded'

__missing_command_FPCMAKE -p -Tavr-embedded Makefile.fpc

make[3]: __missing_command_FPCMAKE: Command not found
Makefile:1450: recipe for target 'fpc_install' failed
make[3]: *** [fpc_install] Error 127

I've tried 3.0.4 as starting compiler but got the same error.  I can generate a 
cross compiler for AVR normally.  Any idea what is missing/wrong here?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Is this the correct way to configure fpc for multiple arm-embedded subarchs?

2017-12-17 Thread Christo
On Mon, 2017-12-04 at 08:22 +0100, Michael Ring wrote:
> Hi Florian!
> 
> I would like to work on this patch, can you share it with me?

> Am 03.12.17 um 19:05 schrieb Florian Klämpfl:
> > 
> > Am 29.11.2017 um 06:36 schrieb Christo:
> > > 
> > > On Sun, 2017-11-26 at 17:19 +0100, Michael Ring wrote:
> > > > 
> > > > I am looking for an easy way to have all cortex-m compilers available
> > > > at the same time to be able to do automated building/testing
> > > There is a similar problem with the AVR target having several
> > > subarchitectures.  One option I think is to have a subarch defined by
> > > the compiler, then it would be easy to lay out the compiled unit
> > > structure in fpc.cfg according to subarch.  I've made an attempt at
> > > adding a subarch define to my local compiler source for AVR, but
> > > haven't developed the idea further.  I'm not a compiler dev so there
> > > may be better options.
> > Subarch directories are imo the best solution, I have a half-backen patch 
> > for this, not yet
> > finished
> > though.

I've missed a critical bit om information until now - there is a config file 
macro replacement
option called $FPCSUBARCH available since r29316.  At the moment I've modified 
my .fpc.cfg to
use the following include to locate RTL units:

#IFDEF EMBEDDED
-Fu~/fpc/$fpcversion/rtl/units/$fpctarget/$FPCSUBARCH/
#ELSE
-Fu~/fpc/$fpcversion/rtl/units/$fpctarget/
#ENDIF

So far I've compiled the AVR RTL for different subarch types, then copied the 
units into their
respective subdirectories.  Once this is done switching between different 
controllers
irrespective of subarch type works.

The additional work required is in my opinion:
* Change makefile to automatically compile all available controllers by subarch 
type and specify
output directory as rtl/units/$FPCTARGET/$FPCSUBARCH/ or as appropriate for 
directory
configuration.
* Update fpc.cfg template to reflect change in default rtl directory structure.

Not sure if this approach will work for all embedded targets though.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Is this the correct way to configure fpc for multiple arm-embedded subarchs?

2017-11-28 Thread Christo
On Sun, 2017-11-26 at 17:19 +0100, Michael Ring wrote:
> I am looking for an easy way to have all cortex-m compilers available
> at the same time to be able to do automated building/testing

There is a similar problem with the AVR target having several
subarchitectures.  One option I think is to have a subarch defined by
the compiler, then it would be easy to lay out the compiled unit
structure in fpc.cfg according to subarch.  I've made an attempt at
adding a subarch define to my local compiler source for AVR, but
haven't developed the idea further.  I'm not a compiler dev so there
may be better options.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Is there a way to execute code after 'initialization' and before 'main', i. e. AddExitProc complement?

2017-11-28 Thread Christo Crause
On 28 Nov 2017 9:04 PM, "Роман via fpc-pascal" <
fpc-pascal@lists.freepascal.org> wrote:
> Can I run SortAndInitialize before 'main' without additional user actions?

Maybe not exactly what you want but you could probably add the
SortAndInitialize procedure to the initialization section of a new unit and
add this unit as the last unit to your program.

This use case is probably a good candidate for using the "section" modifier
to specify initialization sequence. Unfortunately not available in the
compiler for code sections AFAIK.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] installing cross fpc in parallel to systems fpc

2017-11-09 Thread Christo
On Thu, 2017-11-09 at 02:36 +0100, Marc Santhoff wrote:
> Additionally there seems to be no compiler switch for changing the
> configuration file to use, only -n for ignoring it. Is ist possible
> to
> name the .cfg on the command line or how would it be done better?

Yes, specify alternative config file using the @ option.  Use in
conjunction with -n if you want to exclude the default config file.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] compiler option for $J directive

2017-10-10 Thread Christo Crause
>> They were used mainly back at TP times to have procedure local static
variables (cause that is how they behave as inside procedures).
>
> Can we make the {$J-} as default in fpc and objfpc mode for the next
major release?

+1
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial communications: synaser vs FPC's serial unit

2017-08-18 Thread Christo Crause
On Fri, Aug 18, 2017 at 9:39 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> On 2017-08-18 07:51, Christo Crause wrote:
>
>> I've also just noted a typing error in GetSerialPortNames: '/dev/ttyAM*'
>> should rather be '/dev/ttyACM*''
>>
>
> My version also has the first instance (ttyAM*) with a comment "ARM
> boards". Your implementation in the bug report looks a lot better than what
> I have in my synaser copy - cleaner code with less code duplication. Thanks
> for the reply.


Right, not a typo then. Good to learn something new - apparently ttyAMA* is
the device name specified by the ARM AMBA style serial ports driver for
Linux: (
https://code.woboq.org/linux/linux/drivers/tty/serial/amba-pl011.c.html#2514
)

So I looked for a systematic naming convention, but according to the Linux
allocated devices list (
https://static.lwn.net/kerneldoc/admin-guide/devices.html) there is a large
number of tty* names in use for different serial drivers.  Perhaps a
different approach (https://stackoverflow.com/a/9914339) is called for...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial communications: synaser vs FPC's serial unit

2017-08-18 Thread Christo Crause
I see the common Linux port names got added to Synaser (trunk) but the BDS
variants (https://sourceforge.net/p/synalist/bugs/21/) wasn't added.

I've also just noted a typing error in GetSerialPortNames: '/dev/ttyAM*'
should rather be '/dev/ttyACM*''

On Thu, Aug 17, 2017 at 3:45 PM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

>
> Now for the Synaser unit - the one I have is from 2013, and I already
> noticed that there is no support for FreeBSD's /dev/* names to access
> serial ports. Granted I added FreeBSD support to the GetSerialPortNames()
> function in 5 minutes, but this doesn't bode to well then for the Synaser
> unit - what else could be missing that I don't know of?
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC for AVR

2017-06-04 Thread Christo Crause
On 04 Jun 2017 8:29 PM, "Mark Morgan Lloyd" <
markmll.fpc-pas...@telemetry.co.uk> wrote:
>
> What sort of targets are people looking at, what sort of debugging is
available, and has anybody experimented with the "AVR Dragon"?

As a hobbyist I've built some simple projects with arduino and then
standalone mega and tiny range controllers using avr-gcc. Don't have
hardware debugger.

I have recently started avr programming on fpc-pascal. The trunk compiler
is already quite good. One problem is obviously lack of libraries to
interface with peripherals such as LCD, serial, SD cards etc.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Error cross compiling trunk for AVR

2017-05-27 Thread Christo
On Sat, 2017-05-27 at 12:58 +0200, Schindler Karl-Michael wrote:
> > 
> > Am 27.05.2017 um 11:26 schrieb fpc-pascal-request@lists.freepascal.
> > org:
> > 
> > Date: Sat, 27 May 2017 07:58:23 +0200
> > From: Christo <christo.cra...@gmail.com>
> > 
> > A recent change in 3.1.1 seemed to have broken the AVR compiler...

> Same error when building on macOS. Critical commit is 36325 in
> combination with  CROSSOPT="-O3". Build fails for all SUBARCHS of
> avr.
> 
> Bugreport submitted (https://bugs.freepascal.org/view.php?id=31926)

Right, I see that CROSSOPT="-O2" does work. -O2 is probably OK for an
embedded target compiler. Thanks for confirming and reporting the
issue.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Error cross compiling trunk for AVR

2017-05-26 Thread Christo
A recent change in 3.1.1 seemed to have broken the AVR compiler, while
the compiler compiles fine for X86_64-linux. I think the problem
started from r36325:

make clean crossall OS_TARGET=embedded CPU_TARGET=avr SUBARCH=avr5
BINUTILSPREFIX=avr- CROSSOPT="-O3 -XX -CX"
FPC=~/fpc/3.0.2/compiler/ppcx64

When starting to compile the rtl
make[2]: Entering directory '/home/christo/fpc/3.1.1'
make -C rtl all
make[3]: Entering directory '/home/christo/fpc/3.1.1/rtl'
make -C embedded all
make[4]: Entering directory '/home/christo/fpc/3.1.1/rtl/embedded'
/bin/mkdir -p /home/christo/fpc/3.1.1/rtl/units/avr-embedded
/home/christo/fpc/3.1.1/compiler/ppcrossavr -Cpavr5 @rtl.cfg -Ur
-Tembedded -Pavr -XPavr- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../avr -FE.
-FU/home/christo/fpc/3.1.1/rtl/units/avr-embedded -davr -dRELEASE -O3
-XX -CX -Us -Sg system.pp 
/home/christo/fpc/3.1.1/rtl/units/avr-embedded/system.s: Assembler
messages:
/home/christo/fpc/3.1.1/rtl/units/avr-embedded/system.s:7283: Error:
pointer register (X, Y or Z) required
/home/christo/fpc/3.1.1/rtl/units/avr-embedded/system.s:7283: Error:
`,' required
/home/christo/fpc/3.1.1/rtl/units/avr-embedded/system.s:7285: Error:
pointer register (X, Y or Z) required
/home/christo/fpc/3.1.1/rtl/units/avr-embedded/system.s:7285: Error:
`,' required
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Get value of PPChar ?

2017-04-16 Thread Christo Crause
I suppose you have to allocate memory and create a pointer to a pointer to
this memory which you pass to the function.
On 16 Apr 2017 4:58 PM, "fredvs"  wrote:

> Hello.
>
> A C method is defined like this:
>
> MPG123_EXPORT int mpg123_icy(mpg123_handle *mh, char **icy_meta);
>
> and translated in Pascal with this:
>
> function mpg123_icy(mh: Tmpg123_handle; var icy_meta: PPChar): integer;
> cdecl;
>
> OK, the function seems to work because the result = 0 (no error).
>
> But how to retrieve the data icy_meta (PPChar) ?
>
> var
> theicytag : PPChar;
> resu : integer;
> ...
>
> resu := mpg123_icy(ahandle, theicytag);
> if resu = 0 then writeln(theicytag^); --> raise exception + crash
>
> resu := mpg123_icy(ahandle, theicytag);
> if resu = 0 then writeln(theicytag^^); --> also raise exception + crash
>
> Fre;D
>
>
>
>
>
> -
> Many thanks ;-)
> --
> View this message in context: http://free-pascal-general.
> 1045716.n5.nabble.com/Get-value-of-PPChar-tp5728277.html
> Sent from the Free Pascal - General mailing list archive at Nabble.com.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Test for valid ip address

2016-07-28 Thread Christo
On Thu, 2016-07-28 at 10:14 +0200, Koenraad Lelong wrote:
> When I enter 192.168.185.297 (i.e. not a valid ipv4 address) in 
> IPAddressStr I get
> 192.168.185.41
> not the expected error-message.
> 
> According to the rtl-manual :
> 
> function StrToHostAddr(IP: AnsiString) : in_addr
> Description: StrToHostAddr converts the string representation in IP to a 
> host address and returns the host
> address.
> Errors: On error, the host address is filled with zeroes.
> 
> I would think that converting those zeroes to a host-address would yield 
> 0.0.0.0.
> 
> Am I missing something ?
> Is there a better way, without using some other network-library ?

The in_addr IP address type is a packed record of byte, so if an IP
address part larger than 255 is encountered in a string it will be
truncated when copied to the byte record using StrToHostAddr.  This
probably means you have to use some other means of detecting an invalid
address, or add a check for (tmpAddress <> IPAddressStr) to cater for
your situation.

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


Re: [fpc-pascal] AVR Busy Wait implementation

2016-01-14 Thread Christo Crause
There is a lot of useful information in avr-gcc code, once you can see past
the peculiarities of C. See the implementation of avr-gcc's delay here:
cvs.savannah.gnu.org/viewvc/avr-libc/include/util/delay.h and delay_basic.h
in the same folder. Basically they use op codes with fixed cpu cycles to
construct the inside of the loop and use compile time constants to
calculate the number of iterations required for a delay. The focus of the
code is to get accurate delays down to a few cpu cycles.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] How to use serial or usb-ports in linux

2015-09-06 Thread Christo
On Sun, 2015-09-06 at 12:40 +0200, Sven Barth wrote:
> Am 06.09.2015 12:34 schrieb "P. vanderWal" <p.w...@quicknet.nl>:
> >
> > Hello all,
> >  
> > I wrote a program to control a hobby milling machine.(Profiler, see
> Elektor-forum). The programm is written in fpc-pascal and using
> synaser in the windows version for control of the serial port(s).
> > Now I want to use the program in Debian 8... and or Ubuntu 15...
> Compiling and running the present version gives "no permission" for
> the serial/usb ports.
> > Please advise how to get the program running with these ports.
> (lazarus 1.2.4 fpc 2.6.4).
> 
> You need to run your program either as root or ensure that the user
> you run as is allowed to use the ports. 
> You can check that by doing a "ls -l /dev/tty*", which will list the
> user and group of the ttys as well as the permissions. With "groups"
> you should be able to list what groups your user is part of and
> whether one of those matches the group of the ports you try to access.
> 
> Regards,
> Sven
> 

A different flavour of what Sven recommended is to write a udev rule
which adds the permissions to any (or according to some filter rules)
usb device on the fly.  This is particularly useful if the kernel
assigns different names to different devices.  I have the following rule
in /etc/udev/rules.d/50-permissions-on-unclaimed-usb-devices.rules:

 SUBSYSTEM=="usb", ATTRS{bDeviceClass}=="ff", ACTION=="add",
GROUP="groupname", MODE="0664" 

Regards,
Christo

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


Re: [fpc-pascal] EAccessViolation

2015-08-13 Thread Christo Crause
On 13 Aug 2015 10:15 PM, Chris Moody inqu...@greensnakedesign.com wrote:

 Hi all,

 I have this procedure in my program:

 procedure DisplayNode (var node:astring);
 var c, i:integer;
 begin
   i:=SizeOf(node);
   if (i=0) then begin
 writeln ('node was empty / non existant');
 exit;
   end;
   for c:=0 to i do
   writeln (node[c]);// line 85
 end;

 astring is an Array of String

 The code compiles fine, however when I run it I get:

 An unhandled exception occurred at $00400B3A :
 EAccessViolation : Access violation
   $00400B3A line 85 of Dentist.pas
   $00400C8C line 95 of Dentist.pas

 Line 85 is the writeln above, line 95 is where I call this procedure from
the main code.

 How do I track down what is going on?

 If your familiar with PHP, my purpose of this procedure is to basically
emulate the following code:
 pre?php print_r (node); ?/pre

 Thanks in advance,

 Chris

SizeOf(node) will return the size of the pointer to node. I suspect you
want to loop over elements in an array so use length(node) to find out the
number of elements in node.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] License terms for FastHTMLParser

2015-03-08 Thread Christo
While reading up on the history of FastHTMLParser (to find out who/where
the root owner of this unit is) I noticed that the last release (0.4)
from Jazarsoft
(http://web.archive.org/web/20050112010608/http://www.jazarsoft.com/download/fasthtmlparser-0.4-delphi.zip)
 has a permissive license, while the file in the FPC source tree has the GPL 
pasted at the top.  I also see that Andrew Haines is listed as the copyright 
holder in the FPC source, while the original file listed Jazarsoft.  I know 
Andrew developed the chm support in FPC/Lazarus, but it seems as if he isn't 
the original author of this unit.

I think the original license  copyright should be restored for this
unit, any comments?

Best wishes,
Christo

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


Re: [fpc-pascal] fp universal library ?

2014-02-04 Thread Christo
On Sun, 2014-02-02 at 23:13 +0100, Fred van Stappen wrote:

 - Here example for function inside a class of myunit:
 
 library mylib ;
 
 uses
 myunit;
 
 function mylibclassfunction() : integer; cdecl;
 var
 myclass : TMyUnitClass; /// class defined in myunit (if can be a
 variable outside the function)
 
 begin
result := -1 ;
myclass := TMyUnitClass.Create;  
result := myclass.myunitclassfunction() ; // a function of
 myclass  
 end;
 
 exports  
 mylibclassfunction ;
  
 begin
 end.
 

Now what I would like in the compiler is a warning: potential memory
leak at myclass := TMyUnitClass.Create;

;)

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


Re: [fpc-pascal] libusb header translation and OOP wrapper

2012-09-28 Thread Christo
On Tue, 2012-09-25 at 22:16 +0100, Henry Vermaak wrote:
 On 25 September 2012 20:57, Christo christo.cra...@gmail.com wrote:
  Any ideas on how to define the calling convention in the import unit so
  that it is either stdcall or cdecl depending on the target OS?
 
 I've used a macro for this in the past.  E.g. :
 
 {$macro on}
 {$ifdef windows}
   {$define CCONV:=stdcall}
 {$else}
   {$define CCONV:=cdecl}
 {$endif}

Thanks Henry, that macro worked.  I however have a problem statically
linking to the libusbx library on Windows. I've downloaded the Windows
libusbx 1.0.14 library from sourceforge and pointed the compiler to the
mingw32 folder containing libusb-1.0.a.  

It complains about undefined symbols such as: 
project1.lpr(18,1) Error: Undefined symbol: LIBUSB_LIBUSB_INIT
$PLIBUSB_CONTEXT$$LONGINT

I have changed the calling convention to cdecl and then it also
complains:  project1.lpr(18,1) Error: Undefined symbol: _libusb_init

I've managed to load the library dynamically using LoadLibrary and then
loading each function/procedure using GetProcedureAddress.  This works
both on windows and on Linux.

Anyone knows why the static linking fails on Windows XP sp2?  I'm using
fpc 2.6.0 and have also tried the MS32 .lib library with no success.

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


Re: [fpc-pascal] libusb header translation and OOP wrapper

2012-09-25 Thread Christo
On Tue, 2012-09-25 at 09:41 +0100, Graeme Geldenhuys wrote:
 then do...
 
 cd pas-libusb
 git checkout libusb-1.0

Thanks Graeme (and Henry). Obviously I'm new to git and tried commands
similar to svn which didn't work quite as expected.

Regards,
Christo


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


Re: [fpc-pascal] libusb header translation and OOP wrapper

2012-09-25 Thread Christo
On Sun, 2012-09-23 at 23:26 +0200, Johann Glaser wrote:
 Hi!
 
 Some time ago somebody asked about USB support. I've now finished the
 libusb 1.0 header translation and object-oriented wrapper.

Hi Hansi,

I see that the imported functions in libusb.pas are declared with the
cdecl calling convention. According to the libusb header this is so for
all operating systems except windows which is apparently compiled using
the stdcall calling convention.

Any ideas on how to define the calling convention in the import unit so
that it is either stdcall or cdecl depending on the target OS?

Regards,
Christo

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


Re: [fpc-pascal] libusb header translation and OOP wrapper

2012-09-24 Thread Christo
On Sun, 2012-09-23 at 23:26 +0200, Johann Glaser wrote:
 Hi!
 
 Some time ago somebody asked about USB support. I've now finished the
 libusb 1.0 header translation and object-oriented wrapper.
 
 Please find them at
   https://github.com/hansiglaser/pas-libusb/tree/libusb-1.0
 including a few examples to demonstrate the usage.

Hi Hansi,

I'm interested in testing your wrapper.  Unfortunately I cannot clone
the git link above, I get an error (fatal:
https://github.com/hansiglaser/pas-libusb/tree/libusb-1.0/info/refs not
found: did you run git update-server-info on the server?).  I could only
clone what appears to be the master branch using:

git clone https://github.com/hansiglaser/pas-libusb

Unfortunately the master branch appears to be 2 months old. Any idea how
I can clone the libusb-1.0 branch?  I'm new to using git so it may be
something trivial I'm missing.

Regards,
Christo

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


[fpc-pascal] Adding USB library to FPC

2012-05-13 Thread Christo Crause
I have seen several header translations of the various libusb variants
(0.1, 1.0  win32) scattered on the web and forums.  I have also noticed
several dead links, a typo or two and some missing function declaration in
some of the available pascal translations.

Would it not make sense to include a FPC package with a header translation
for say the libusb 0.1  win32 libraries?  I mention these two since they
seem to be compatible at an API level, hence would be ideal for
cross-platform support.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Object Pascal operating system

2008-12-07 Thread Crause, Christo (JC)
Some proof of the concept: ClassiOS
(http://www.petros-project.com/index.php/products/classios.html) was
written in Delphi. Not an open source project, but it shows it can be
done.

Christo


NOTICE: Please note that this eMail, and the contents thereof, 
is subject to the standard Sasol eMail legal notice which may be found at: 
http://www.sasol.com/legalnotices   
   

If you cannot access the legal notice through the URL attached and you wish 
to receive a copy thereof please send an eMail to 
[EMAIL PROTECTED]

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


[fpc-pascal] RE: Succ() and Pred() operations

2008-04-10 Thread Crause, Christo (JC)
 Message: 9
 Date: Wed, 9 Apr 2008 13:55:40 -0800
 From: Ricardo Vi?gas [EMAIL PROTECTED]
 Subject: [fpc-pascal] Succ() and Pred() operations
 
 Hi there!
 
 I have installed FPC 2.2.0 [2007/09/09] a few days ago on my 
 WinXP-Pro-SP2, and I'm just taking a Web Tutorial on the language.
 when I come to User defined variable types, I decided to 
 make the following test:
 
 Program Test (Output);
 Type Vars = (var0, var1);
 Var x : Vars;
 Begin
x := var1;
x := Succ (x);
Writeln ( Ord(x) );
x := var0;
x := Pred (x);
Writeln ( Ord(x) );  
End.
 
 It compiled and executed without error, and returned 
 following 2 lines:
 2
 -1
 
 Is that supposed to be the correct output, or should it have 
 pointed an error during execution?
 The first symbol of the set has value 0, and second one, 
 value 1. To which symbols corresponds the values 2 and -1?

You can enable range checking {$R+}, which should then raise an error
if the value goes out of range. Tested with FPC 2.3.1.

Regards,
Christo

NOTICE: Please note that this eMail, and the contents thereof, 
is subject to the standard Sasol eMail legal notice which may be found at: 
http://www.sasol.com/legalnotices   
   

If you cannot access the legal notice through the URL attached and you wish 
to receive a copy thereof please send an eMail to 
[EMAIL PROTECTED]

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


Re: [fpc-pascal] Basic question about TStringList

2008-03-28 Thread Crause, Christo (JC)
 From: [EMAIL PROTECTED]

 As a consequence I have another question. Suppose I have a function  
 that returns a TStringList:
 
 Myfunction(): TStringList;
 
 I must have inside a line like:
 
 Result:=TStringList.Create;
 
 Let A be a TStringList, I have two ways to catch the result 
 of my function:
 
 A:=Myfunction();
 
 or
 
 A.Assign(Myfunction());
 
 In the first case, if do A.Free, I release the memory 
 allocated by the  
 function. What's arriving in the second case? I can do A.Free, but  
 does that action will also release the memory allocated by 
 the function?
 
 By the way, do you have some tricks to detect this kind of error?

This consequence of returning references to newly created objects is a
very subtle one and I have seen some spectacular memory leaks caused by
this practice.  My programming convention is to try to always call
.Create
and .Free in the same context if possible i.e.

procedure Myfunction(const ASL: TStringList);
begin
// add stuff to ASL
end;

And in code using this function:

SL := TStringList.Create;
Myfunction(SL);
// do stuff
SL.Free;

Not quite bullet proof yet, since one can call Myfunction without
actually
instantiating SL, but at least that should give you a runtime error that
should be easy to trace.

Regards
Christo Crause

NOTICE: Please note that this eMail, and the contents thereof, 
is subject to the standard Sasol eMail legal notice which may be found at: 
http://www.sasol.com/legalnotices   
   

If you cannot access the legal notice through the URL attached and you wish 
to receive a copy thereof please send an eMail to 
[EMAIL PROTECTED]

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


[fpc-pascal] RE: fpc-pascal Digest, Vol 43, Issue 21

2008-03-17 Thread Crause, Christo (JC)
 From: Codebue Fabio - P-Soft [EMAIL PROTECTED]
 
 I learn about all your tips... but nothing todo. I try to summarize
 I'm using firebird 2.0.3 in windows vista environment. pudf 
 was compiled
 with fpc 2.0.4 and created with lazarus 0.9.22

Did you upgrade or installed a newer version of Firebird over an older
one?  On my machine I installed a newer version over the older one, and
it installed the new version in a subdirectory under Firebird, but the
old
UDF folder was not removed.  I ended up with the following structure,
which lead me to putting UDF dll's in the wrong folder:

C:\Program Files\Firebird\UDF = old UDF folder, not used by my Firebird
2.0
C:\Program Files\Firebird\Firebird_2_0\UDF = new and correct UDF folder

Note that this situation is specific to the way I upgraded and your
folder
structures may look different.  Just ensure that the UDF folder you are
using is at the same level as the bin folder containing the version you
are running.

Regards,
Christo

NOTICE: Please note that this eMail, and the contents thereof, 
is subject to the standard Sasol eMail legal notice which may be found at: 
http://www.sasol.com/legalnotices   
   

If you cannot access the legal notice through the URL attached and you wish 
to receive a copy thereof please send an eMail to 
[EMAIL PROTECTED]

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


[fpc-pascal] RE: Firebird UDF

2008-03-13 Thread Crause, Christo (JC)
 From: Codebue Fabio - P-Soft
...
 function pround(var valore: real; ndec: integer):real;export; 
...
 DECLARE EXTERNAL FUNCTION pround 
 DOUBLE PRECISION, INTEGER 
 RETURNS DOUBLE PRECISION BY VALUE 
 ENTRY_POINT 'pround' MODULE_NAME 'pudf'; 
 
 if I use it with an instruction like this 
 
 select round(123.1233, 2) as nrounded from rdb$database 
 
 I have back this error 
 
 Invalid token. 
 invalid request BLR at offset 59. 
 function PROUND is not defined. 
 module name or entrypoint could not be found. 
 
 do you have some idea regarding this error?

I guess you made a typo in your select statement,
since it calls round, not pround.

It would appear that Firebird cannot load the 
dll/so or find the entry point to the function
in the dll.  Did you copy the dll/so to the UDF
subdirectory of your Firebird diretory?  You
could also try adding the extension (.dll or .so)
to the name of the library.  If you are using Linux
you should also check the permissions on the library
and make sure that Firebird can load it.  If this
doesn't work, open the Firebird.conf file and check
what the value for UdfAccess is.

You may also have to change the calling convension of
your function to cdecl, since that is what Firebird expects.

Regards,
Christo

NOTICE: Please note that this eMail, and the contents thereof, 
is subject to the standard Sasol eMail legal notice which may be found at: 
http://www.sasol.com/legalnotices   
   

If you cannot access the legal notice through the URL attached and you wish 
to receive a copy thereof please send an eMail to 
[EMAIL PROTECTED]

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


[fpc-pascal] OT: RE: fp not available

2005-11-15 Thread Crause, Christo (JC)
 From: Vincent Snijders [EMAIL PROTECTED]
 Subject: Re: [fpc-pascal] RE: fp not available
 To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org

 Please, write error messages with svn versions of both fpc 
 and lazarus to the 
 lazarus mailing list or submit a bug report on 
 http://www.lazarus.freepascal.org/mantis/main_page.php
 
 But make sure you are the latest svn version of both fpc and 
 lazarus. A number of 
 fixes have been made since the latest releases.
 
 As far as I know, lazarus can be compiled and started on linux-amd64
 
 Vincent.

Thanks Vincent, I had another look at the compiler errors and realised
that the fpc.cfg file was not set up correctly to work with the SVN
version of FPC.  Lazarus does indeed compile with both latest fpc 2.0.1
and 2.1.1

Regards,
Christo Crause

NOTICE: Please note that this eMail, and the contents thereof, 
is subject to the standard Sasol eMail legal notice which may be found at: 
http://www.sasol.com/legalnotices   
   

If you cannot access the legal notice through the URL attached and you wish 
to receive a copy thereof please send an eMail to 
[EMAIL PROTECTED]


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


[fpc-pascal] RE: fp not available

2005-11-14 Thread Crause, Christo (JC)
 Date: Sun, 13 Nov 2005 17:50:46 +0100
 From: J.L. Blom [EMAIL PROTECTED]
 Subject: [fpc-pascal] fp not available

 I have an AMD64 running the 64-bit version of Fedora4 and I 
 haven't found a specific 64-bit version of fpc. 
 I hope somebody can give me some clues.
 Joep

You can download x86_64 fpc 2.0.0 rpm's from:
http://www.freepascal.org/down-x86_64-linux-ftp.freepascal.org.html

I am interested in knowing whether you get Lazarus working in 64 bit
mode.  I have compiled it with fpc 2.0.0, but get runtime errors.  I
could not get Lazarus to compile with 64 bit fpc 2.0.1 or 2.1.1 yet.

Regards,
Christo Crause

NOTICE: Please note that this eMail, and the contents thereof, 
is subject to the standard Sasol eMail legal notice which may be found at: 
http://www.sasol.com/legalnotices   
   

If you cannot access the legal notice through the URL attached and you wish 
to receive a copy thereof please send an eMail to 
[EMAIL PROTECTED]


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