Re: [fpc-pascal] Floating point question

2024-02-22 Thread Peter B via fpc-pascal

On 22/02/2024 14:22, Jean SUZINEAU via fpc-pascal wrote:

As far as I know Extended is not supported on Linux.


This is wrong, sorry.  I'm using Extended on Linux and it works just fine.


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


Re: [fpc-pascal] What's in Hello World

2024-01-08 Thread Peter B via fpc-pascal

On 07/01/2024 16:07, James Richters via fpc-pascal wrote:

Try building with smartlinking, -XX

I never knew there was an option for smartlinking.   I'm using the FPC text
IDE, I see various options like
Generate Smaller Code, and level 1, 2, and 3 optimizations, but I don't see
anything specifically called smartlinking.
If you run fpc from the console, with no parameters or options, you 
should see a

full set of options listed.

  
Is it the same as Generate Smaller Code?

No. That is a compile option -Os
-XX is a link time option.


   or if not, is there another way to
turn it on in the textmode IDE?

No idea. Its easy enough if you compile from the command line.
fpc -Os -XX hello.pas

If stripping is not on by default, also use -Xs

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


Re: [fpc-pascal] What's in Hello World

2024-01-07 Thread Peter B via fpc-pascal




Try building with smartlinking, -XX
I get 35k


Thats with 3.2.2 on linux

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


Re: [fpc-pascal] What's in Hello World

2024-01-07 Thread Peter B via fpc-pascal

On 06/01/2024 19:05, Matthew Phillips via fpc-pascal wrote:

I compiled the Hello World program from the docs and noticed that it's
435k. Compared to a lot of newer languages, like Golang, that's not bad
at all.

I then compiled the equivalent C program with gcc which came out at
33k. So I'm just curious, where does the difference comes from?
Could it be that fpc is including some parts that are not being used in
this simple of a program or is more going on?

Like I said, purely a curiosity, not intended as a criticism. Cheers.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Try building with smartlinking, -XX
I get 35k


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


Re: [fpc-pascal] Strings greater than 255 characters

2023-12-19 Thread Peter B via fpc-pascal

On 19/12/2023 11:36, James Richters via fpc-pascal wrote:


I did notice that I cannot have a file of Ansistrings…

Myfile : File of Ansistring;

Causes a compiler error:

Error: Typed files cannot contain reference-counted types.



I would just define the file as 'Text'.
Can then Readln into an Ansistring.


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


Re: [fpc-pascal] Program crash - read the error messages

2023-09-01 Thread Peter B via fpc-pascal

Can you compile the crashing program with  -gl    ?

That should give you a useful stack dump with line numbers.




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


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

2023-06-16 Thread Peter B via fpc-pascal

On 16/06/2023 11:55, Giuliano Colla via fpc-pascal wrote:


Is that the intended behavior of compiler?



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.


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


Re: [fpc-pascal] Passing around Pascal strings vs AnsiString

2023-06-15 Thread Peter B via fpc-pascal

On 14/06/2023 14:20, Hairy Pixels via fpc-pascal wrote:

I was curious, if you had a Pascal (short) string and it was going to be passed 
around often would that be slower than using an AnsiString since its size is 
that of a pointer? I always prefer short strings when I know the length will be 
less than 255 but can copying that value between function calls add up to be 
more than the cost of allocating and reference counting the AnsiString?

Regards,
Ryan Joseph

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



Value parameter passing will be slower for shortstring, but anything else is 
likely to be much faster.
Best to profile the app if concerned about this.

I recall many years ago, an application that ran about 50 times slower, 
following a Delphi upgrade.
It turned out the issue was switching the string default from pascal 
shortstring to ansi.

YMMV, but I would always use shortsting locally where length permits.


Cheers,
Peter

P.S.  Think this was D4
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Size of set.

2023-05-23 Thread Peter B via fpc-pascal

On 23/05/2023 01:14, Mikael Backman via fpc-pascal wrote:

Hi,
basic questions here.

Is there any way to decide the number of elements in a set?
 there any way to  traverse the elements in a set?

Regards Mikael

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



You can transverse a set with
    for ... in

See "loop with elements" in
https://wiki.freepascal.org/For


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


Re: [fpc-pascal] pointer to char vs pchar

2023-03-24 Thread Peter B via fpc-pascal

On 24/03/2023 14:29, Martin Frb via fpc-pascal wrote:

On 24/03/2023 15:04, Benito van der Zander via fpc-pascal wrote:
why is a pointer to a char not a pchar (for type helpers)? 


My guess: For the same reason that "p2" fails in the below. Distinct type.
May be assignment compatible, but a type of it's own.


My understanding is that pchars are supposed to be null terminated,
while the char in a pointer to a char might not be.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Lack of PIC code support for m68k CPU (was: FPC crashes with Internal error 200502052 compiling shared library on m68k)

2023-03-10 Thread Peter B via fpc-pascal

Thanks for your interest in this Charlie.

Just requesting that maybe any more thoughts on this subject could go to the 
bug report?

https://gitlab.com/freepascal.org/fpc/source/-/issues/40177

As this thread will probably be lost in the mists of time,
but the bug report should stay open till fixed.


FWIW, I don't have any m68k hardware to test any fix, just noticed that the 
c-evo-dh build crashed on Debian.


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


Re: [fpc-pascal] Lack of PIC code support for m68k CPU (was: FPC crashes with Internal error 200502052 compiling shared library on m68k)

2023-03-09 Thread Peter B via fpc-pascal

On 08/03/2023 21:34, Pierre Muller via fpc-pascal wrote:


For m68k,
(3104) Compiling StdAI.lpr
(3104) Compiling Protocol.pas
Protocol.pas(1963,36) Fatal: Internal error 200502052
Fatal: (1018) Compilation aborted
Error: /usr/bin/ppc68k returned an error exitcode
make[1]: *** [debian/rules:27: override_dh_auto_build] Error 1

Here again, it is a unit that is compiled and generate the internal error: 
200502052
After inspection inside the code source,
it seems that indeed pic code is not supported by
the Free Pascal compiler for m68k CPU...
(not even in current trunk version).
I don't know if anyone ever worked on this...



Hi Pierre,

Thanks for your info.

Note, I have raised a bug report for this crash now.
https://gitlab.com/freepascal.org/fpc/source/-/issues/40177

Given that -fpic is unsupported on m68k,
perhaps the compiler could abort an attempted -fpic compilation there with a 
meaningful error message,
rather that crash out with an internal error?

Cheers,
Peter

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


[fpc-pascal] FPC crashes with Internal error 200502052 compiling shared library on m68k

2023-03-03 Thread Peter B via fpc-pascal

On Debian 12 (Bookworm) FPC release version 3.2.2 crashes on m68k when trying 
to build a shared library.

See
https://buildd.debian.org/status/package.php?p=doublecmd

https://buildd.debian.org/status/package.php?p=c-evo-dh

Scroll down to "Tail of log for ... m68k:"


I have searched the bug tracker and can't see any related issues.

I don't use m68k, so I'm not affected myself with this, just F.Y.I.
Should I raise it as an issue on GitLib?


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


Re: [fpc-pascal] Get highest element of a StringList

2022-09-12 Thread Peter B via fpc-pascal

On 12/09/2022 07:52, Jean SUZINEAU via fpc-pascal wrote:

As Bart suggested, you can use too the for/in loop:  for s in sl do WriteLn( s);



And that is IMHO by far the most elegant, and least error prone, representation.

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


Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread Peter B via fpc-pascal

I suggest trying without optimisations and/or using cmem, to see if that 
changes the outcome.

Also, if the array is corrupted prior to the setlength, then iterating the 
array with a trivial
  with... Writeln(Color)
or whatever, should trigger an exception.

That could then be used at various parts of the program to identify the point 
of corruption,
which might seem unrelated to array in question if the heap is getting messed 
up somehow.


Cheers,
Peter

P.S.

I had a strange (possible) heap corruption issue with a large program a year 
ago that broke stringlists.
I never found the cause, and after many minor code changes, the problem just 
dissappeared.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Arguments gets corrupted with anonymous nested function

2022-09-07 Thread Peter B via fpc-pascal

I'm wondering if this is related to
https://gitlab.com/freepascal.org/fpc/source/-/issues/38703

That caused a parameter corruption in a standard function.
https://lists.freepascal.org/pipermail/fpc-pascal/2022-March/060361.html

Should be easy to check. Just try compiling with -O1


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