Re: [fpc-pascal] Does ReallocMem(p,0) always set p to nil?

2007-05-07 Thread Vincent Snijders

Vincent Snijders schreef:

Hi,

Consider this piece of code:

var
  p: pointer;
begin
  p := getmem(100);
  reallocmem(p,0);
  p := nil;
end.

Do I need to do p:=nil, if I want to be sure that p contains nil?

I saw that both system.SysReAllocMem and cmem.CReAllocMem do this, is 
size=0, but the docs at 
http://lazarus-ccr.sourceforge.net/docs/rtl/system/reallocmem.html don't 
mention this, so I don't know if I can be trust that is the case for 
always for all memory managers.


Tough question apparently. Let's try to word it differently.

After reallocmem(p,0) I observed that p is always nil. Is this an implementation 
detail (subject to change) or part of the specification of reallocmem?


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


Re: [fpc-pascal] set output directory for resources

2007-05-07 Thread Vincent Snijders

Peter Vreman schreef:

Vincent Snijders schreef:

Hi,

If I compile a unit which contains {$R wincemenures.res} a file named
wincemenures.or is created in the source directory, even if I have set
-FU or -FE. What parameter do I need to pass to the compile to move the
.or file to the unit output directory?

Nobody answered, so I decided to dive into the compiler source myself
and I think always the source directory is used.

Attached patch changes this to the output directory of the currently
compiled module. Is this ok?


ok



Committed in r7276. Can it be merged to the fixes branch?

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


Re: [fpc-pascal] Does ReallocMem(p,0) always set p to nil?

2007-05-07 Thread Michael Van Canneyt


On Mon, 7 May 2007, Vincent Snijders wrote:

 Vincent Snijders schreef:
  Hi,
  
  Consider this piece of code:
  
  var
p: pointer;
  begin
p := getmem(100);
reallocmem(p,0);
p := nil;
  end.
  
  Do I need to do p:=nil, if I want to be sure that p contains nil?
  
  I saw that both system.SysReAllocMem and cmem.CReAllocMem do this, is
  size=0, but the docs at
  http://lazarus-ccr.sourceforge.net/docs/rtl/system/reallocmem.html don't
  mention this, so I don't know if I can be trust that is the case for always
  for all memory managers.
 
 Tough question apparently. Let's try to word it differently.
 
 After reallocmem(p,0) I observed that p is always nil. Is this an
 implementation detail (subject to change) or part of the specification of
 reallocmem?

This is part of the specification.

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


[fpc-pascal] libsndfile library

2007-05-07 Thread Tiziano_mk


The real question is How to play a sound file on Linux in the same way 
I can do it on windows?.


this is my experience:

On Windows I do:

uses mmsystem
...
sndPlaySound('filename.wav',0);
...

and it works gracefully.


On Linux I found only the sndfile unit (packages\extra\sndfile\).

This require the presence of sndlife library on the distribution.

In my PC I have Ubuntu 6.06 with libsndfile installed (dynamic library 
only):


/usr/lib/libsndfile.so.1.0.12
/usr/lib/libsndfile.so.1

So, I try to compile the example sfplay.pp, and after some corrections 
it compiles but after that the linker stops with the infamous message:


/usr/bin/ld: cannot find -lsndfile
sound.pas(34,1) Error: Error while linking

(note: the -Fl statements in fpc.cfg are tuned on /usr/ and /usr/lib/ so 
the real problem is that I don't have the static library)


There is a chance to have my program linked on a system where I only 
have the Dynamic Libray?


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


Re: [fpc-pascal] Does ReallocMem(p,0) always set p to nil?

2007-05-07 Thread Vincent Snijders

Michael Van Canneyt schreef:


On Mon, 7 May 2007, Vincent Snijders wrote:


Vincent Snijders schreef:

Hi,

Consider this piece of code:

var
  p: pointer;
begin
  p := getmem(100);
  reallocmem(p,0);
  p := nil;
end.

Do I need to do p:=nil, if I want to be sure that p contains nil?

I saw that both system.SysReAllocMem and cmem.CReAllocMem do this, is
size=0, but the docs at
http://lazarus-ccr.sourceforge.net/docs/rtl/system/reallocmem.html don't
mention this, so I don't know if I can be trust that is the case for always
for all memory managers.

Tough question apparently. Let's try to word it differently.

After reallocmem(p,0) I observed that p is always nil. Is this an
implementation detail (subject to change) or part of the specification of
reallocmem?


This is part of the specification.



Thanks. Can you add this to the documentation?

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


Re: [fpc-pascal] libsndfile library

2007-05-07 Thread Marco van de Voort
 On Linux I found only the sndfile unit (packages\extra\sndfile\).
 
 This require the presence of sndlife library on the distribution.
 
 In my PC I have Ubuntu 6.06 with libsndfile installed (dynamic library 
 only):

 
 /usr/lib/libsndfile.so.1.0.12
 /usr/lib/libsndfile.so.1

Your Linux system is not properly configured for libsndfile development.

You miss the symlink from libsndfile.so - libsndfile.so.1.0.12

 /usr/bin/ld: cannot find -lsndfile
 sound.pas(34,1) Error: Error while linking
 
 (note: the -Fl statements in fpc.cfg are tuned on /usr/ and /usr/lib/ so 
 the real problem is that I don't have the static library)
 
 There is a chance to have my program linked on a system where I only 
 have the Dynamic Libray?

A -lxxx searches for libxxx.so only, not for variants. Create symlinks if
necessary or try to install packages that might create symlinks (like -dev
packages on RedHat)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] set output directory for resources

2007-05-07 Thread Graeme Geldenhuys

On 5/7/07, Vincent Snijders [EMAIL PROTECTED] wrote:


Committed in r7276. Can it be merged to the fixes branch?



That would be great...


--
Graeme Geldenhuys

There's no place like S34° 03.168'  E018° 49.342'
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] libsndfile library

2007-05-07 Thread Tiziano_mk

Marco van de Voort wrote:

On Linux I found only the sndfile unit (packages\extra\sndfile\).

This require the presence of sndlife library on the distribution.

In my PC I have Ubuntu 6.06 with libsndfile installed (dynamic library 
only):



/usr/lib/libsndfile.so.1.0.12
/usr/lib/libsndfile.so.1


Your Linux system is not properly configured for libsndfile development.
neither for other kind of develpment libraries (ncurses, sqlite, etc, 
etc) indeed.
Each time I try something that needs a link to a library I have to spend 
my weekends trying to fild what is missing... :-(




You miss the symlink from libsndfile.so - libsndfile.so.1.0.12


/usr/bin/ld: cannot find -lsndfile
sound.pas(34,1) Error: Error while linking

(note: the -Fl statements in fpc.cfg are tuned on /usr/ and /usr/lib/ so 
the real problem is that I don't have the static library)


There is a chance to have my program linked on a system where I only 
have the Dynamic Libray?


A -lxxx searches for libxxx.so only, not for variants. Create symlinks if
necessary or try to install packages that might create symlinks (like -dev
packages on RedHat)


Ok, I'll try that, thanks. But the same problem could happen in other 
PCs where my program could be deployed...


So I turn back to the inital question: there is a more affordable way to 
play a sound file on a Linux Machine?


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


[fpc-pascal] LongWord

2007-05-07 Thread Carsten Bager
I have written a small demo program that gives a runetime error when it
runs.
Is it the compiler or is it me?

Regards carsten

 The program 
program word32test;
{$RANGECHECKS ON}
{$OVERFLOWCHECKS ON}
{$S+ STACK CHECKING ON}
{$SMARTLINK ON}
{$TYPEINFO ON}
{$LONGSTRINGS OFF}


var
  a,b,c:longWord;

Begin
  a:=10;
  b:=5;
  writeLn('a=',a,'  b=',b);
  c:= a - b;
  writeLn('Resultat : ',c);
End.
--- The program output --
$ ./word32test
a=10  b=5
Runtime error 215 at $81CC
  $81CC  main,  line 17 of word32test.pp
  $80F4


 The compiler output 

./makearm.shFpc/Pas/Linux/Test/Word32 #
+-+
| CFG file ver. 1.00 d. 19/9-2006 |
+-+
+-+
| Cross compiling for ARM 9 Linux |
+-+
+--+
| Standard lib |
+--+
Hint: End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 2.0.4 [2006/08/29] for arm
Copyright (c) 1993-2006 by Florian Klaempfl
Target OS: Linux for ARM
Compiling word32test.pp
Assembling word32test
Assembling with smartlinking word32test
/Fpc/ArmBin/ar: creating libpword32test.a
Linking word32test
19 Lines compiled, 0.5 sec
Med venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk


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


Re: [fpc-pascal] LongWord

2007-05-07 Thread Jonas Maebe


On 7 mei 2007, at 14:15, Carsten Bager wrote:

I have written a small demo program that gives a runetime error  
when it

runs.
Is it the compiler or is it me?


See http://www.freepascal.org/mantis/view.php?id=8321 for a long  
discussion on this topic.



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


Re: [fpc-pascal] LongWord

2007-05-07 Thread Daniël Mantione


Op Mon, 7 May 2007, schreef Jonas Maebe:

 
 On 7 mei 2007, at 14:15, Carsten Bager wrote:
 
  I have written a small demo program that gives a runetime error when it
  runs.
  Is it the compiler or is it me?
 
 See http://www.freepascal.org/mantis/view.php?id=8321 for a long discussion on
 this topic.

10 - 5 = 5

This is a different issue; 10-5 should not overflow regardless of the 
type that is used for the calculation.

Daniël___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] LongWord

2007-05-07 Thread Carsten Bager
  I have written a small demo program that gives a runetime error

 See http://www.freepascal.org/mantis/view.php?id=8321 for a long
 discussion on this topic.

I do not think that the discussion covers my case, all my numbers are
positive and the result is positive.

I have just tried the example with the 386 linux compiler it returns 5 as one
would expect.

---
./make386.shFpc/Pas/Linux/Test/Word32 #
+-+
| CFG file ver. 1.00 d. 19/9-2006 |
+-+
+--+
| Compiling for I386 Linux |
+--+
Hint: End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 2.0.4 [2006/08/20] for i386
Copyright (c) 1993-2006 by Florian Klaempfl
Target OS: Linux for i386
Compiling word32test.pp
Linking word32test
19 Lines compiled, 0.4 sec

-

./word32testFpc/Pas/Linux/Test/Word32 #
a=10  b=5
Resultat : 5
Med venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk


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


Re: [fpc-pascal] LongWord

2007-05-07 Thread Bernd Mueller

Jonas,


On 7 mei 2007, at 14:15, Carsten Bager wrote:


I have written a small demo program that gives a runetime error when it
runs.
Is it the compiler or is it me?


See http://www.freepascal.org/mantis/view.php?id=8321 for a long 
discussion on this topic.



I think I have hit a similar case with the following code:

{$mode objfpc}{$H+}
program test; { FPC 2.0.4}
var
   w: Word;
begin
   w:= ;
   if lo(w)  lo(w + (5 - 5)) then
  writeln('This is a little bit unexpected');
end.

What would you suggest as a workaround? Using the mod operator?

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


Re: [fpc-pascal] libsndfile library

2007-05-07 Thread bartek
  A -lxxx searches for libxxx.so only, not for variants. Create symlinks if
  necessary or try to install packages that might create symlinks (like
  -dev packages on RedHat)
Ubuntu also has x-dev packages. apt-get install lbsndfile1-dev should fix your 
problem without need to tinker.


 Ok, I'll try that, thanks. But the same problem could happen in other
 PCs where my program could be deployed...

 So I turn back to the inital question: there is a more affordable way to
 play a sound file on a Linux Machine?

SDL. This library, not counting the graphics part, is ingenious IMHO.

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


Re: [fpc-pascal] libsndfile library

2007-05-07 Thread Marco van de Voort
  
  /usr/lib/libsndfile.so.1.0.12
  /usr/lib/libsndfile.so.1
  
  Your Linux system is not properly configured for libsndfile development.

 neither for other kind of develpment libraries (ncurses, sqlite, etc, 
 etc) indeed.
 Each time I try something that needs a link to a library I have to spend 
 my weekends trying to fild what is missing... :-(

How this is handled is distro specific. I suggest you read the docs for your
distribution to see how it is done.

 Ok, I'll try that, thanks. But the same problem could happen in other 
 PCs where my program could be deployed...

Yes and no.

No: It will probably add a dependancy to libsndfile.so.1  (not .so
or .so.1.0.12). And that is installed.

Yes: the library must be present, and  under that name, and there is no
guarantee. But that at least will be ok for Ubuntu.

The only way around it is to enter the complex package building and add a
dependancy on the file, a system that varies from distro to distro, unix
variant to unix variant (iow, to package your app as a package for each
(family of) distribution(s)).
 
 So I turn back to the inital question: there is a more affordable way to 
 play a sound file on a Linux Machine?

No. This is a general library and packaging problematic. No library is 100%
guaranteed on Linux, even glibc can be replaced by some embedded variant.


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


[fpc-pascal] Widestrings length and character iteration

2007-05-07 Thread Christos Chryssochoidis

Hi,

Are there any rtl functions to compute the length (in characters) of  
a widestring and to iterate over its characters?
 In my system (Mac OS X/fpc 2.1.3), a widestring is implemented as a  
UTF-8 encoded string, as I found out.


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


Re: [fpc-pascal] Widestrings length and character iteration

2007-05-07 Thread Daniël Mantione


Op Mon, 7 May 2007, schreef Christos Chryssochoidis:

 Hi,
 
 Are there any rtl functions to compute the length (in characters) of a
 widestring and to iterate over its characters?

If you treat it as UCS-2: length(widestring_variable)

  In my system (Mac OS X/fpc 2.1.3), a widestring is implemented as a UTF-8
 encoded string, as I found out.

Not possible, a widestring is UCS-2/UTF-16.

Daniël___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] LongWord

2007-05-07 Thread Jonas Maebe


On 7 mei 2007, at 15:14, Bernd Mueller wrote:

See http://www.freepascal.org/mantis/view.php?id=8321 for a long  
discussion on this topic.

I think I have hit a similar case with the following code:

{$mode objfpc}{$H+}
program test; { FPC 2.0.4}
var
   w: Word;
begin
   w:= ;
   if lo(w)  lo(w + (5 - 5)) then
  writeln('This is a little bit unexpected');
end.

What would you suggest as a workaround? Using the mod operator?


Yes, or using byte()/word(), or typecasting the result of the  
calculation. The result of lo/hi depends on the type of the expression.



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


Re: [fpc-pascal] libsndfile library

2007-05-07 Thread Marc Santhoff
Am Montag, den 07.05.2007, 10:01 +0200 schrieb Tiziano_mk:
 Marco van de Voort wrote:
  On Linux I found only the sndfile unit (packages\extra\sndfile\).
 
  This require the presence of sndlife library on the distribution.
 
  In my PC I have Ubuntu 6.06 with libsndfile installed (dynamic library 
  only):
  
  /usr/lib/libsndfile.so.1.0.12
  /usr/lib/libsndfile.so.1
  
  Your Linux system is not properly configured for libsndfile development.
 neither for other kind of develpment libraries (ncurses, sqlite, etc, 
 etc) indeed.
 Each time I try something that needs a link to a library I have to spend 
 my weekends trying to fild what is missing... :-(

I'm not using Linux, but doesn't ldconfig exist there?

On FreeBSD you can do:

$ ldconfig -r|grep sndfile
463:-lsndfile.1 = /usr/local/lib/libsndfile.so.1

So you know what's there. AFAIR in the link.sh script in the build
directory after fpc failed there are hints on where fpc is searching.

After asking ldconfig after what it found you could look further:

$ ls -l  /usr/local/lib/libsndfile*
-rw-r--r--  1 root  wheel  425514 26 Mai  2005 /usr/local/lib/libsndfile.a
lrwxr-xr-x  1 root  wheel  15 26 Mai  2005 /usr/local/lib/libsndfile.so - 
libsndfile.so.1
-rwxr-xr-x  1 root  wheel  359904 26 Mai  2005 /usr/local/lib/libsndfile.so.1

(sorry for long lines)

If you set the link a short ldconfig -R rescans the library dirs and it
should work.

  
  You miss the symlink from libsndfile.so - libsndfile.so.1.0.12
  
  /usr/bin/ld: cannot find -lsndfile
  sound.pas(34,1) Error: Error while linking
 
  (note: the -Fl statements in fpc.cfg are tuned on /usr/ and /usr/lib/ so 
  the real problem is that I don't have the static library)
 
  There is a chance to have my program linked on a system where I only 
  have the Dynamic Libray?
  
  A -lxxx searches for libxxx.so only, not for variants. Create symlinks if
  necessary or try to install packages that might create symlinks (like -dev
  packages on RedHat)
 
 Ok, I'll try that, thanks. But the same problem could happen in other 
 PCs where my program could be deployed...

Try man ldconfig and read more about the linux specific switches ...

Hope it helps,
Marc


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


RV: [fpc-pascal] Program exited with code 01

2007-05-07 Thread josepascual (almudi)
Any suggestion?

-Mensaje original-
De: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] En nombre de josepascual
(almudi)
Enviado el: viernes, 04 de mayo de 2007 10:28
Para: 'FPC-Pascal users discussions'
Asunto: [fpc-pascal] Program exited with code 01

Hi Everyone,


I have compiled hello_eabi_arm (hello world!) with ppcrossarm and -GfSOFT
option.

I can run a hello world program with no problem (ldd say me there is not
libraries needed)
but if I use dl.pp I received next error (write below), ldd say libdl and
libc.so.6 are needed.

any suggestion? how can I discover what file or directory is missing for
program,

=
$ ./hello_eabi_arm
-bash: ./ hello_eabi_arm: No such file or directory 

$ gdb hello_eabi_arm 

GNU gdb 6.5-debian Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type show copying to see the conditions.
There is absolutely no warranty for GDB.  Type show warranty for details.
This GDB was configured as arm-linux-gnueabi...Using host libthread_db
library /lib/libthread_db.so.1.

(gdb) run
Starting program: /tmp/hello_eabi_arm
/bin/bash: /tmp/hello_eabi_arm: No such file or directory
/bin/bash: /tmp/hello_eabi_arm: Success

Program exited with code 01.
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers and track explicitly
loaded dynamic code.
You can't do that without a process to debug.
(gdb)
=

thanks,
regards

Jose Pascual


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

__ Informacisn de NOD32, revisisn 2238 (20070503) __

Este mensaje ha sido analizado con NOD32 antivirus system
http://www.nod32.com


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


Re: RV: [fpc-pascal] Program exited with code 01

2007-05-07 Thread Henry Vermaak

On 07/05/07, josepascual (almudi) [EMAIL PROTECTED] wrote:

$ ./hello_eabi_arm
-bash: ./ hello_eabi_arm: No such file or directory

...
...
...

(gdb) run
Starting program: /tmp/hello_eabi_arm
/bin/bash: /tmp/hello_eabi_arm: No such file or directory


so the file doesn't exist.  did it not compile?  if you want to link
to these libraries, you need to make sure that they are somewhere in a
lib directory under your toolchain.  usually your cross-ld will be
configured to look for the library in the right place, but otherwise
you might have to give the option to fpc to look in the right dir for
those libs.

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


[fpc-pascal] Class Memory Table Size

2007-05-07 Thread Andrew Haines
Hi,

In this page
http://www.freepascal.org/docs-html/prog/progsu139.html#x189-1950008.2.13
in the VMT +0 is the Size of object type data and the same number in
the negative is stored at +4. How important is it that this number is
not changed after the object is created? I want to store a number
especially at +0. What is stored after that does not matter.

The reason for this is, I want to trick gtk into thinking that a TObject
is really a GObject. This is where the TypeID for GType's are stored. I
know this won't work for most GObject's, but I am only implementing this
for a GInterface which is looked up by the TypeID, so that is all I need.

I've tested this and it is working. But what horrible things can happen?

Thanks,

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