Re: [fpc-pascal] Bitpacked bug?

2019-05-12 Thread Victor Campillo

On 12/5/19 18:21, Luca Olivetti wrote:


With that last case, aren't you just defining one bit in the bitpacked 
record?
In that case 


Thanks Luca, the case was the problem, I wanted a bitpacked record of 
word, this was a silly copy / paste error.


--
Victor Campillo

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

Re: [fpc-pascal] Problem linking external libs on Linux

2019-05-12 Thread fredvs

https://bugs.freepascal.org/view.php?id=32367



-
Many thanks ;-)
--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Problem linking external libs on Linux

2019-05-12 Thread Sven Barth via fpc-pascal
Anthony Walter  schrieb am So., 12. Mai 2019, 20:42:

> Okay, so I need to install the dev versions of any package I want to link
> against. But when my program is distributed it will link at load time
> correctly to the non dev versions.
>

It links against the version the development version linked against. If the
user has a different version installed (even if they have the development
package installed) the application won't load of course.

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

Re: [fpc-pascal] Bitpacked bug?

2019-05-12 Thread Luca Olivetti

El 12/5/19 a les 17:58, Victor Campillo ha escrit:

Hi,

I think I found a bug with bitpackeds records.

I have the next record.

   TBitpacked = packed record
     Case Integer Of
   0 : (Word :  Word);
   1 : (Byte :  array [0..1] of Byte);
   2 : (Boolean: bitpacked Array [0..15] of boolean);
   3 : (Bit : bitpacked Record
   case integer of
     0: (bit0: Boolean);
     1: (bit1: Boolean);
     2: (bit2: Boolean);
     3: (bit3: Boolean);
     4: (bit4: Boolean);
     5: (bit5: Boolean);
     6: (bit6: Boolean);
     7: (bit7: Boolean);
     8: (bit8: Boolean);
     9: (bit9: Boolean);
     10: (bit10: Boolean);
     11: (bit11: Boolean);
     12: (bit12: Boolean);
     13: (bit13: Boolean);
     14: (bit14: Boolean);
     15: (bit15: Boolean);
   end);
     end;


With that last case, aren't you just defining one bit in the bitpacked 
record?

In that case


   pp.Word:=0;
   pp.Bit.bit1:=true;
   writeln(pp.Byte[0]); // This prints 1 -- WRONG
   writeln(pp.Boolean[0]); // This prints True -- WRONG
   writeln(pp.Boolean[1]); // This prints False -- WRONG


this would be correct.


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

Re: [fpc-pascal] Problem linking external libs on Linux

2019-05-12 Thread Anthony Walter
Okay, so I need to install the dev versions of any package I want to link
against. But when my program is distributed it will link at load time
correctly to the non dev versions.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Problem linking external libs on Linux

2019-05-12 Thread Sven Barth via fpc-pascal
Anthony Walter  schrieb am So., 12. Mai 2019, 18:41:

> For example suppose I want to write some pascal code linking to an
> external functions like so:
>
> const
>   libsdl2 = 'libSDL2-2.0.so.0';
>
> function SDL_Init(flags: Uint32): LongInt; cdecl; external libsdl2;
> procedure SDL_Quit; cdecl; external libsdl2;
>
> And when I try to compile the linking will likely failed because something
> is happening where the libsdl2 constant of 'libSDL2-2.0.so.0' is being
> converted to 'SDL2-2.0' at some point during the compilation or linking
> stage when working on Linux.
>

This is indeed how it is supposed to work. You are supposed to link against
the development library so that the linker can pick up the correct, real
library.

Regards,
Sven

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

Re: [fpc-pascal] Bitpacked bug?

2019-05-12 Thread Victor Campillo

On 12/5/19 18:36, Jeppe Johansen wrote:
With this layout bit0 to bit15 will all point to bit0. You probably 
didn't mean to do the case inside the bitpacked record



Yes, you are right, I don't want the case there, copy/paste error.

One hour looking that record declaration and I could not point out that 
mistake, time to left the laptop and grab a beer :)


Thank you Jeppe.

Best Regards.

--
Victor Campillo

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

Re: [fpc-pascal] Bitpacked bug?

2019-05-12 Thread Jeppe Johansen

On 5/12/19 5:58 PM, Victor Campillo wrote:

case integer of
    0: (bit0: Boolean);
    1: (bit1: Boolean);
    2: (bit2: Boolean);
    3: (bit3: Boolean);
    4: (bit4: Boolean);
    5: (bit5: Boolean);
    6: (bit6: Boolean);
    7: (bit7: Boolean);
    8: (bit8: Boolean);
    9: (bit9: Boolean);
    10: (bit10: Boolean);
    11: (bit11: Boolean);
    12: (bit12: Boolean);
    13: (bit13: Boolean);
    14: (bit14: Boolean);
    15: (bit15: Boolean);
  end); 


With this layout bit0 to bit15 will all point to bit0. You probably 
didn't mean to do the case inside the bitpacked record


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

[fpc-pascal] Problem linking external libs on Linux

2019-05-12 Thread Anthony Walter
I'm am not sure how long I've ignored this problem, but can someone explain
to me the proper way to get FPC and Lazarus to allow linking of external
shared object files without the need to create "friendly" symbolic link
names FPC and Lazarus can see?

For example suppose I want to write some pascal code linking to an external
functions like so:

const
  libsdl2 = 'libSDL2-2.0.so.0';

function SDL_Init(flags: Uint32): LongInt; cdecl; external libsdl2;
procedure SDL_Quit; cdecl; external libsdl2;

And when I try to compile the linking will likely failed because something
is happening where the libsdl2 constant of 'libSDL2-2.0.so.0' is being
converted to 'SDL2-2.0' at some point during the compilation or linking
stage when working on Linux.

It is taking the constant, removing and 'lib' prefix, and anything after a
'.so.'. So it's losing the '.0' at the end of my constant.

If I create symbolic link on my system like so, then the compilation and
linking works:

sudo ln -s /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 /usr/lib/
libSDL2-2.0.so
 - or alternately -
sudo ln
-s /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 /usr/lib/x86_64-linux-gnu/
libSDL2-2.0.so

But I don't feel this is correct. I should be able to explicitly specify
the standard name of the file name for the library which is
'libSDL2-2.0.so.0' and the compilation and linking stages should be able to
use it with the '.0' at the end.

So my question is, what do I need to do either in Lazarus settings,
fpc.cfg, or some other setting (possibly on my OS) to allow
'libSDL2-2.0.so.0' to work as a valid external library name without the
need to create symbolic links?

By the way, I am using Ubuntu 16.4 64 bit if that is at all relevant.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC does not compile after revision 42042

2019-05-12 Thread Victor Campillo

On 12/5/19 17:41, Michael Van Canneyt wrote:


Should be fixed.


Indeed.

That was fast, thank you.

--
Victor Campillo

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

[fpc-pascal] Bitpacked bug?

2019-05-12 Thread Victor Campillo

Hi,

I think I found a bug with bitpackeds records.

I have the next record.

  TBitpacked = packed record
    Case Integer Of
  0 : (Word :  Word);
  1 : (Byte :  array [0..1] of Byte);
  2 : (Boolean: bitpacked Array [0..15] of boolean);
  3 : (Bit : bitpacked Record
  case integer of
    0: (bit0: Boolean);
    1: (bit1: Boolean);
    2: (bit2: Boolean);
    3: (bit3: Boolean);
    4: (bit4: Boolean);
    5: (bit5: Boolean);
    6: (bit6: Boolean);
    7: (bit7: Boolean);
    8: (bit8: Boolean);
    9: (bit9: Boolean);
    10: (bit10: Boolean);
    11: (bit11: Boolean);
    12: (bit12: Boolean);
    13: (bit13: Boolean);
    14: (bit14: Boolean);
    15: (bit15: Boolean);
  end);
    end;

See the program below.

var

  pp:TBitpacked;

begin
  pp.Word:=0;
  pp.Boolean[1]:=true;
  writeln(pp.Byte[0]); // This prints 2 -- OK
  writeln(pp.Boolean[0]); // This prints False -- OK
  writeln(pp.Boolean[1]); // This prints True -- OK

  pp.Word:=0;
  pp.Bit.bit1:=true;
  writeln(pp.Byte[0]); // This prints 1 -- WRONG
  writeln(pp.Boolean[0]); // This prints True -- WRONG
  writeln(pp.Boolean[1]); // This prints False -- WRONG

  pp.Word:=0;
  pp.Boolean[8]:=true;
  writeln(pp.Byte[0]); // This prints 0 -- OK
  writeln(pp.Byte[1]); // This prints 1 -- OK
  writeln(pp.Boolean[0]); // This prints False -- OK
  writeln(pp.Boolean[8]); // This prints True -- OK

  pp.Word:=0;
  pp.Bit.bit8:=true;
  writeln(pp.Byte[0]); // This prints 1 -- WRONG
  writeln(pp.Byte[1]); // This prints 0 -- WRONG
  writeln(pp.Boolean[0]); // This prints True -- WRONG
  writeln(pp.Boolean[8]); // This prints False -- WRONG
end.


Is this a known issue or there is something wrong with my code?

I tested this with FPC 3.0.4 and trunk, same result.

Best Regards.

--
Victor Campillo

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

Re: [fpc-pascal] FPC does not compile after revision 42042

2019-05-12 Thread Michael Van Canneyt



On Sun, 12 May 2019, Victor Campillo wrote:


Hi,

After revision 42042 (last commit made by Michael Van Canneyt) I got 
this error trying to compile FPC on Linux x86_64.


    streams.inc(1865,37) Error: Can't determine which overloaded 
function to call

    classes.pp(57) Fatal: There were 1 errors compiling module, stopping
    Fatal: Compilation aborted


Should be fixed.

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

[fpc-pascal] FPC does not compile after revision 42042

2019-05-12 Thread Victor Campillo

Hi,

After revision 42042 (last commit made by Michael Van Canneyt) I got 
this error trying to compile FPC on Linux x86_64.


    streams.inc(1865,37) Error: Can't determine which overloaded 
function to call

    classes.pp(57) Fatal: There were 1 errors compiling module, stopping
    Fatal: Compilation aborted


Best regards.

--
Victor Campillo

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