Re: [fpc-pascal] Calculating CRC16?

2022-10-25 Thread Giuliano Colla via fpc-pascal
Il 25/10/22 09:58, Marco Borsari via fpc-pascal ha scritto: On Tue, 25 Oct 2022 08:30:19 +0200 Bo Berglund via fpc-pascal wrote: Is there some package or code available somewhere which can calculate the CRC16 value over a byte array of some 1000 bytes? http://www.retroarchive.org/swag/CRC/ind

[fpc-pascal] Why in {$mode delphi} it works and in {$mode objfpc} it doesn't?

2023-01-16 Thread Giuliano Colla via fpc-pascal
I stumbled into a problem I don't understand. I'm developing a little program for an ftp client. In order to connect to the site I need the site address from the site name, and the libc gethostbyname() provides the required information. gethostbyname returns a PHostEnt type which is declared

Re: [fpc-pascal] Why in {$mode delphi} it works and in {$mode objfpc} it doesn't?

2023-01-16 Thread Giuliano Colla via fpc-pascal
Il 16/01/23 20:32, Michael Van Canneyt ha scritto: On Mon, 16 Jan 2023, Giuliano Colla via fpc-pascal wrote: .I stumbled into a problem I don't understand. Should that not simply be Addr := Pin_addr(HostEnt.h_addr^) (if addr is a pointer) or addr:=Pin_addr(HostEnt.h_addr^)^ if

Re: [fpc-pascal] Why in {$mode delphi} it works and in {$mode objfpc} it doesn't?

2023-01-16 Thread Giuliano Colla via fpc-pascal
Il 16/01/23 20:58, Marco van de Voort via fpc-pascal ha scritto: On 16-1-2023 20:56, Giuliano Colla via fpc-pascal wrote: No chance. Addr is a pointer (of type Pin_addr) but Addr := Pin_addr(HostEnt.h_addr^) works only if mode is Delphi. In objfpc it raises exactly the same error. A

Re: [fpc-pascal] Why in {$mode delphi} it works and in {$mode objfpc} it doesn't?

2023-01-16 Thread Giuliano Colla via fpc-pascal
Il 16/01/23 22:23, Mattias Gaertner via fpc-pascal ha scritto: On Mon, 16 Jan 2023 22:12:52 +0100 Mattias Gaertner via fpc-pascal wrote: On Mon, 16 Jan 2023 19:50:34 +0100 Giuliano Colla via fpc-pascal wrote: I stumbled into a problem I don't understand. I'm developing a litt

[fpc-pascal] star operator on enum types

2023-01-26 Thread Giuliano Colla via fpc-pascal
I found in a fpc program a statement sort of: Type   TSomeType = (a,b,c)   TaType = set of TSometype var   setA,setB: TaType; . *if setA * setB = [] then doSomething*; which I found very smart to detect if the two sets have some common elements, but I've been unable to find in the fpc docum

Re: [fpc-pascal] star operator on enum types

2023-01-26 Thread Giuliano Colla via fpc-pascal
Il 26/01/2023 18:52, Sven Barth via fpc-pascal ha scritto: Giuliano Colla via fpc-pascal <mailto:fpc-pascal@lists.freepascal.org>> schrieb am Do., 26. Jan. 2023, 18:43: I found in a fpc program a statement sort of: Type   TSomeType = (a,b,c)   TaType = set of TSometyp

Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-22 Thread Giuliano Colla via fpc-pascal
Il 22/03/2023 11:18, Bo Berglund via fpc-pascal ha scritto: If I have fpc 3.2.2 inbstalled on Windows 10 x64 I assume it is a 64 bit target exe which will be the output, right? If in Project Options -> Config and Target ->Target OS you specify Win32, you'll get a 32 bit exe (which is what Delph

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

2023-04-01 Thread Giuliano Colla via fpc-pascal
Il 01/04/2023 21:56, Bo Berglund via fpc-pascal ha scritto: I need to read and write data to an EEPROM connected by I2C on a RaspberryPi4. The I2C channel is found in /dev as i2c-1: $ ll /dev/i2* crw-rw 1 root i2c 89, 1 2019-02-14 11:12 /dev/i2c-1 In this channel the EEPROM CAT24C128 is at

Re: [fpc-pascal] Declaring an array as var or not in function calls?

2023-04-12 Thread Giuliano Colla via fpc-pascal
Il 12/04/2023 21:17, Bo Berglund via fpc-pascal ha scritto: And if so, what is the rule for*when* to use var in function call argument lists for items that will be changed inside the called function and used afterwards? Your Wargs is defined as an open array, i.e. its length is unknown at comp

Re: [fpc-pascal] override and virtual: was SetFileTime

2023-05-03 Thread Giuliano Colla via fpc-pascal
Il 03/05/23 16:44, Steve Litt via fpc-pascal ha scritto: José Mejuto via fpc-pascal said on Wed, 3 May 2023 11:35:50 +0200 Hello, Attached is a dirty implementation of "touch" for junctions == TTouchJunction = class(TCustomApplication)

[fpc-pascal] Wrong assignment detected only run time without warning

2023-06-16 Thread Giuliano Colla via fpc-pascal
I made a stupid error. My code: TFileObj = Class(TObject) [snip] Size: Integer; [snip] end; procedure TForm1.FillDir(FileData : TSearchRec); ... FFIleObj.Size := FileData.Size; ... but TSearchRec structure is: TRawbyteSearchRec = Record [snip] Size : Int64;

Re: [fpc-pascal] Wrong assignment detected only run time without warning

2023-06-16 Thread Giuliano Colla via fpc-pascal
Il 16/06/23 13:36, Peter B via fpc-pascal ha scritto: Yes. Assigning a 64bit integer to a 32bit one is fine as long as the range is within bounds. Range of a variable can only be checked at run time. I can understand that. But the compiler generates quite a number of warning for potential lo

Re: [fpc-pascal] Wrong assignment detected only run time without warning

2023-06-16 Thread Giuliano Colla via fpc-pascal
Il 16/06/23 15:02, Tomas Hajny via fpc-pascal ha scritto: If you compile with -CO, you should get at least a hint (if you enable displaying them, of course): I believed that -Co was enough. I'll add -CO to the debug options. Thanks. Giuliano ___

Re: [fpc-pascal] Legitimate use of for and break

2023-06-20 Thread Giuliano Colla via fpc-pascal
Il 20/06/2023 09:05, Hairy Pixels via fpc-pascal ha scritto: Educators continuously have stupid ideas that don't work out as intended in the real world. I would love to see them make a real program that does something difficult and not use early breaks. I assume them they forbid early exits