Re: [fpc-pascal] Forin Test

2009-11-07 Thread Paul Ishenin

darekm wrote:
I've play with forin construction. To my work I need more than one per 
collection.

In attach is one of example program.
Can someone review it. is this proper construction.

operator enumerator (AEnumerator: TEnumerator): TEnumerator;
begin
 Result := AEnumerator
end;

It is a bit hackish but I see problems with it.

 for i in List.up do
   WriteLn(i);

will be possible to transform into

 for i in List using Up do
   WriteLn(i);

or

 for i in List using GetEnumerator(DoUpArgument)

current "for i in List" will be just short form of "for i in List using 
GetEnumerator"


Best regards,
Paul Ishenin.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Forin Test

2009-11-07 Thread Dariusz Mazur

Paul Ishenin pisze:

darekm wrote:
I've play with forin construction. To my work I need more than one 
per collection.

In attach is one of example program.
Can someone review it. is this proper construction.

operator enumerator (AEnumerator: TEnumerator): TEnumerator;
begin
 Result := AEnumerator
end;

It is a bit hackish but I see problems with it.

Where?
Its work now with current compilator. Are You plan to disable this?



 for i in List.up do
   WriteLn(i);

will be possible to transform into

 for i in List using Up do
   WriteLn(i);

or

 for i in List using GetEnumerator(DoUpArgument)

current "for i in List" will be just short form of "for i in List 
using GetEnumerator"

But this complicate both: source and compilator.
And second: You cant pass enumerator as param.

procedure MyProc(aEnum: tObject);
var
  i : integer;
begin
 for i in aEnum do
  writeln(i);
end;


MyProc(List.up);
MyProc(List)




--
 Darek




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


[fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Andrew Brunner
Hi there,

I just got a laptop that came with Windows Seven.  I have complete
automation scripts with my Ubuntu boxes but NONE of the commands to
"make" FPC translate for me.

I poured over wikis and blogs for info and even found the official
(link below).
http://wiki.lazarus.freepascal.org/Installing_Lazarus#FPC_Sources_for_Windows
 <<< Someone's TODO.

If anyone has a batch file with the propper commands send it here.. I
really want to start developing on this laptop.  Will go dual boot
shortly if I have to but I'd rather just have the ability to develop
on both platforms (using Lazarus/FPC).

Thanks to anyone who can /will help.  -Andy
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Forin Test

2009-11-07 Thread Paul Ishenin

Dariusz Mazur wrote:

Where?
Its work now with current compilator. Are You plan to disable this?

I made a typo: read 'I see *no* problems with this'.

 for i in List using GetEnumerator(DoUpArgument)

current "for i in List" will be just short form of "for i in List 
using GetEnumerator"

But this complicate both: source and compilator.

Why compilcate? I thought vice versa it will simplify the user source code.

And second: You cant pass enumerator as param.
Maybe you understood me wrong? I proposed the 'using' keyword as an 
extension to the current implementation. It would not be required. If 
not used then it will work as now but if used then compiler will search 
for the given identifier and use it instead of operator/GetEnumerator 
method.


Best regards,
Paul Ishenin.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Vincent Snijders

Andrew Brunner schreef:

Hi there,

I just got a laptop that came with Windows Seven.  I have complete
automation scripts with my Ubuntu boxes but NONE of the commands to
"make" FPC translate for me.

I poured over wikis and blogs for info and even found the official
(link below).
http://wiki.lazarus.freepascal.org/Installing_Lazarus#FPC_Sources_for_Windows
 <<< Someone's TODO.

If anyone has a batch file with the propper commands send it here.. I
really want to start developing on this laptop.  Will go dual boot
shortly if I have to but I'd rather just have the ability to develop
on both platforms (using Lazarus/FPC).



Did you install fpc 2.2.4 and set the %PATH% to the directory that 
contains the fpc.exe executable?


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


Re: [fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Andrew Brunner
Yes.  From any folder in command prompt I get fpc access.  I just
don't know the make commands and parameters.

-Andy

On Sat, Nov 7, 2009 at 7:31 AM, Vincent Snijders
 wrote:
> Andrew Brunner schreef:
>>
>> Hi there,
>>
>> I just got a laptop that came with Windows Seven.  I have complete
>> automation scripts with my Ubuntu boxes but NONE of the commands to
>> "make" FPC translate for me.
>>
>> I poured over wikis and blogs for info and even found the official
>> (link below).
>>
>> http://wiki.lazarus.freepascal.org/Installing_Lazarus#FPC_Sources_for_Windows
>>  <<< Someone's TODO.
>>
>> If anyone has a batch file with the propper commands send it here.. I
>> really want to start developing on this laptop.  Will go dual boot
>> shortly if I have to but I'd rather just have the ability to develop
>> on both platforms (using Lazarus/FPC).
>>
>
> Did you install fpc 2.2.4 and set the %PATH% to the directory that contains
> the fpc.exe executable?
>
> Vincent
> ___
> fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Jonas Maebe

Andrew Brunner wrote on Sat, 07 Nov 2009:


Yes.  From any folder in command prompt I get fpc access.  I just
don't know the make commands and parameters.


make all
make install INSTALL_PREFIX=c:\path\without\spaces

(and make sure the sources are also installed in a hierarchy without  
spaces in the directory names)



Jonas


This message was sent using IMP, the Internet Messaging Program.

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


Re: [fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Vincent Snijders

Andrew Brunner schreef:

Yes.  From any folder in command prompt I get fpc access.  I just
don't know the make commands and parameters.


Did you try the same as on linux (that is what the wiki suggested).

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


Re: [fpc-pascal] Forin Test

2009-11-07 Thread Dariusz Mazur

Paul Ishenin pisze:

Dariusz Mazur wrote:

Where?
Its work now with current compilator. Are You plan to disable this?

I made a typo: read 'I see *no* problems with this'.

 for i in List using GetEnumerator(DoUpArgument)

current "for i in List" will be just short form of "for i in List 
using GetEnumerator"

But this complicate both: source and compilator.
Why compilcate? I thought vice versa it will simplify the user source 
code.

Can You give example of this:
where
 for i in List using GetEnumerator
is better than
 for i in List.GetEnumerator

And second: You cant pass enumerator as param.
Maybe you understood me wrong? I proposed the 'using' keyword as an 
extension to the current implementation. It would not be required. If 
not used then it will work as now but if used then compiler will 
search for the given identifier and use it instead of 
operator/GetEnumerator method.

this is third method,
Should be good point to implement this (pascal always has very simple 
semantic and very strong type checking)
Of course you then you can use any enumerator with any collection, but 
it will be better?

How many errors we then invoke?

--
 Darek




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


[fpc-pascal] Is there call back function when read resourcestring

2009-11-07 Thread Zaher Dirkey
Is there call back function when read string resourcestring, like as

resourcestring
  sHello := 'Hello';

s:= sHello; //<-- here


like TWideStringManager is there a manager for resourcestring?

Thanks.

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


Re: [fpc-pascal] Forin Test

2009-11-07 Thread Paul Ishenin

Dariusz Mazur wrote:

Can You give example of this:
where
 for i in List using GetEnumerator
is better than
 for i in List.GetEnumerator
Of course. for-in loop expect to have a collection not an enumerator. 
What enumerator should for-in loop to choose in the next case:


[example]
TMyListEnumerator = class
public
 function GetEnumerator: TMyListEnumeratorEnumerator;
 function MoveNext: Boolean;
 property Current: something;
end;

TMyList = class
public
 function GetEnumerator: TMyListEnumerator;
 function GetAnotherEnumerator: TMyListAnotherEnumerator;
end;

var
 List: TMyList;
begin
 for i in List.GetEnumerator do
end;
[/example]

Loop will choose TMyListEnumeratorEnumerator, but is it desired?

'using' keyword solves this ambiguity very easy:

for CollectionElement in Collection using CollectionEnumerator do


And second: You cant pass enumerator as param.
Maybe you understood me wrong? I proposed the 'using' keyword as an 
extension to the current implementation. It would not be required. If 
not used then it will work as now but if used then compiler will 
search for the given identifier and use it instead of 
operator/GetEnumerator method.

this is third method,
Should be good point to implement this (pascal always has very simple 
semantic and very strong type checking)
Of course you then you can use any enumerator with any collection, but 
it will be better?

How many errors we then invoke?

Much less.

Best regards,
Paul Ishenin.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Is there call back function when read resourcestring

2009-11-07 Thread Michael Van Canneyt



On Sat, 7 Nov 2009, Zaher Dirkey wrote:


Is there call back function when read string resourcestring, like as

resourcestring
 sHello := 'Hello';

s:= sHello; //<-- here


like TWideStringManager is there a manager for resourcestring?


No. 
The resourcestring tables can be manipulated with some of the objpas unit routines.

They are documented.

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


Re: [fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Andrew Brunner
Make Install PREFIX worked but it required Elevated User Status.  And
to do this under Seven you must right click the icon for command
prompt and select run as administrator.  Running command prompt as an
administrator will enable the installation properly from the command
prompt.  Otherwise the make install command fails.

Next I wannt to do the make source install.  I had a problem with the
source install.  The MyPrefix I used was c:\FPC. Where were the files
supposed to be copied?  I'm updating the Wiki site for Windows and I
just want to make sure my instructions are verified... And I didn't
get the source copied using make install sourceinstall PREFIX=MyPrefix

On Sat, Nov 7, 2009 at 7:54 AM, Vincent Snijders
 wrote:
> Andrew Brunner schreef:
>>
>> Yes.  From any folder in command prompt I get fpc access.  I just
>> don't know the make commands and parameters.
>
> Did you try the same as on linux (that is what the wiki suggested).
>
> Vincent
> ___
> fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Andrew Brunner
C:\Developer\FPC>make install sourceinstall PREFIX=C:\FPC

make -C win32 exampleinstall
make[4]: Entering directory `C:/Developer/FPC/rtl/win32'
make[4]: Nothing to be done for `exampleinstall'.
make[4]: Leaving directory `C:/Developer/FPC/rtl/win32'
make[3]: Leaving directory `C:/Developer/FPC/rtl'
make[2]: Leaving directory `C:/Developer/FPC'
make[1]: Leaving directory `C:/Developer/FPC'
make installother FPC=C:/Developer/FPC/compiler/ppc386.exe ZIPDESTDIR=C:/Develop
er/FPC FPCMAKE=C:/Developer/FPC/utils/fpcm/fpcmake.exe
make[1]: Entering directory `C:/Developer/FPC'
make packages_distinstall FPC=C:/Developer/FPC/compiler/ppc386.exe ZIPDESTDIR=C:
/Developer/FPC FPCMAKE=C:/Developer/FPC/utils/fpcm/fpcmake.exe
make[2]: Entering directory `C:/Developer/FPC'
make -C packages distinstall
make[3]: Entering directory `C:/Developer/FPC/packages'
make -C hash distinstall
make[4]: Entering directory `C:/Developer/FPC/packages/hash'
C:/Developer/FPC/utils/fpcm/fpcmake.exe -p -Ti386-win32 Makefile.fpc
Processing Makefile.fpc
 Writing Package.fpc
C:/FPC/bin/i386-Win32/ginstall.exe -m 755 -d C:\FPC/units/i386-win32/hash
C:/FPC/bin/i386-Win32/cp.exe -fp Package.fpc C:\FPC/units/i386-win32/hash
C:/FPC/bin/i386-Win32/ginstall.exe -m 755 -d C:\FPC/units/i386-win32/hash
C:/FPC/bin/i386-Win32/cp.exe -fp units/i386-win32/md5.ppu units/i386-win32/crc.p
pu units/i386-win32/ntlm.ppu units/i386-win32/uuid.ppu units/i386-win32/sha1.ppu
 C:\FPC/units/i386-win32/hash
C:/FPC/bin/i386-Win32/cp.exe -fp units/i386-win32/md5.o units/i386-win32/crc.o u
nits/i386-win32/ntlm.o units/i386-win32/uuid.o units/i386-win32/sha1.o C:\FPC/un
its/i386-win32/hash
make -C examples distclean
make[5]: Entering directory `C:/Developer/FPC/packages/hash/examples'
C:/FPC/bin/i386-Win32/rm.exe -f mdtest.exe crctest.exe sha1test.exe mdtest.o crc
test.o sha1test.o libpmdtest.a libpcrctest.a libpsha1test.a libimpmdtest.a libim
pcrctest.a libimpsha1test.a
C:/FPC/bin/i386-Win32/rm.exe -rf units
C:/FPC/bin/i386-Win32/rm.exe -f *.o *.ppu *.rst *.s *.a *.dll *.ppl
C:/FPC/bin/i386-Win32/rm.exe -rf *.sl
C:/FPC/bin/i386-Win32/rm.exe -f fpcmade.* Package.fpc ppas.bat script.res link.r
es
C:/FPC/bin/i386-Win32/rm.exe -f *_ppas.bat
make[5]: Leaving directory `C:/Developer/FPC/packages/hash/examples'
C:/FPC/bin/i386-Win32/ginstall.exe -m 755 -d C:\FPC/examples/hash
C:/FPC/bin/i386-Win32/cp.exe -Rfp examples/* C:\FPC/examples/hash
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/all-wcprops': Permi
ssion denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/entries': Permissio
n denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/crctest.p
as.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/Makefile.
fpc.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/Makefile.
svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/md5.ref.s
vn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/mdtest.pa
s.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/sha1test.
pp.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/crctest.p
as.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/Makefile.
fpc.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/Makefile.
svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/md5.ref.s
vn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/mdtest.pa
s.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/sha1test.
pp.svn-base': Permission denied
make[4]: *** [fpc_exampleinstall] Error 1
make[4]: Leaving directory `C:/Developer/FPC/packages/hash'
make[3]: *** [hash_distinstall] Error 2
make[3]: Leaving directory `C:/Developer/FPC/packages'
make[2]: *** [packages_distinstall] Error 2
make[2]: Leaving directory `C:/Developer/FPC'
make[1]: *** [installother] Error 2
make[1]: Leaving directory `C:/Developer/FPC'
make: *** [install] Error 2

Another problem I had from 2.2.4 is that the new binaries were mising
a few items like make and some others... So I had to merge missing
files to get 2.5.1 to work.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Jonas Maebe

Andrew Brunner wrote on Sat, 07 Nov 2009:


C:/FPC/bin/i386-Win32/cp.exe -Rfp examples/* C:\FPC/examples/hash
cp.exe: cannot remove old link to  
`C:/FPC/examples/hash/.svn/all-wcprops': Permi

ssion denied


You have to build/install an exported copy under Windows due to a bug  
in cp.exe there. First perform


C:\Developer\FPC> svn export . c:\Developer\FPCExport

Then build/install from c:\Developer\FPCExport


Another problem I had from 2.2.4 is that the new binaries were mising
a few items like make and some others... So I had to merge missing
files to get 2.5.1 to work.


make is not an FPC utility, it is not built when building FPC. It's an  
external program that's used with FPC. That's why you have to copy  
those over if you want to start from scratch.



Jonas


This message was sent using IMP, the Internet Messaging Program.

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


[fpc-pascal] Debugger for the fpc available?

2009-11-07 Thread Holger Bruns

Hi,

while writing some Pascal code, I am still looking for a debugger, which 
works like the turbo debugger, in a similar way. I would love it to get 
a clue.


Best regards, Holger

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


Re: [fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Marco van de Voort
In our previous episode, Andrew Brunner said:
> Make Install PREFIX worked but it required Elevated User Status.  And
> to do this under Seven you must right click the icon for command
> prompt and select run as administrator. 

This will be fixed in 2.4.0 (as long as you install to a location that
doesn't need privileges)

Many workarounds for these kinds of problems are in the buildfaq

http://www.stack.nl/~marcov/buildfaq.pdf
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Andrew Brunner
On Sat, Nov 7, 2009 at 12:21 PM, Jonas Maebe  wrote:
>
> You have to build/install an exported copy under Windows due to a bug in
> cp.exe there. First perform
>
> C:\Developer\FPC> svn export . c:\Developer\FPCExport
>
> Then build/install from c:\Developer\FPCExport

Well, if this is a bug I guess it would work itself out later.

> make is not an FPC utility, it is not built when building FPC. It's an
> external program that's used with FPC. That's why you have to copy those
> over if you want to start from scratch.

Ok, under linux make must be readily available w/o FPC.  Ummm.  This
really complicates things for ppl who don't know what they are doing
under Windows.  Linux is FAR EASIER to manage FPC/Lazarus via
SVN/trunk.

I suppose a command line utilty could be made to list PREFIX FPC
folder for missing files that are not present AFTER make install and
that would cover the merging automatcially.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Forin Test

2009-11-07 Thread Dariusz Mazur

Paul Ishenin pisze:
Of course. for-in loop expect to have a collection not an enumerator. 
What enumerator should for-in loop to choose in the next case:


[example]
TMyListEnumerator = class
public
 function GetEnumerator: TMyListEnumeratorEnumerator;
 function MoveNext: Boolean;
 property Current: something;
end;

TMyList = class
public
 function GetEnumerator: TMyListEnumerator;
 function GetAnotherEnumerator: TMyListAnotherEnumerator;
end;

var
 List: TMyList;
begin
 for i in List.GetEnumerator do
end;
[/example]

Loop will choose TMyListEnumeratorEnumerator, but is it desired?

'using' keyword solves this ambiguity very easy:

for CollectionElement in Collection using CollectionEnumerator do

with hack with trivial operator we receive the same:
 for CollectionElement in Collection.CollectionEnumerator do

but what about
 for CollectionElement in Collection using TreeEnumerator do
where TreeEnumerator cant traverse thought Collection




And second: You cant pass enumerator as param.
Maybe you understood me wrong? I proposed the 'using' keyword as an 
extension to the current implementation. It would not be required. 
If not used then it will work as now but if used then compiler will 
search for the given identifier and use it instead of 
operator/GetEnumerator method.

this is third method,
Should be good point to implement this (pascal always has very simple 
semantic and very strong type checking)
Of course you then you can use any enumerator with any collection, 
but it will be better?

How many errors we then invoke?

Much less.

I can't resist.
But I have another proposition. Because we add so many variants to forin 
construction, can be added once more.

[example]
for list do 
[/example]

where we omit in keywords and iteration variable
That will be nice solution for some  expression or in some transactional 
patterns like:

[example]
initfun;
while stopfun do begin
end;


try
 lock;
...
finally
unlock;
end;
[example]



I think its not break any current behavior. Of course I can do the same 
today, but I need variable, which would not be used.

In below example we can omit declaration of i variable;
[example]
var
 i : integer;
begin
 for i in lock do begin
   procedureNotUseI;
 end;
end;
[/example]



--
 Darek




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


[fpc-pascal] TCustomApplication and QApplication

2009-11-07 Thread ik
Hello,

I'm trying to write a console program that uses some features of QT (webkit
and printing from webkit) using FPC 2.2.5
QT have QApplication that I require to use because that I require the
printing issues and settings the URL.

QApplication is very similar to TCustomApplication in it's approach, so my
question is how can I bind between the two so when I'm making
QApplication_exec, it will execute the code of TCustomApplication.run and do
what I require from it to do ?

Thanks,
Ido

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

[fpc-pascal] Stack checking in dynamic libraries

2009-11-07 Thread cobines
Hello,

I have found out the following during development of my project and
wanted to ask for some explanation.

I have a dynamic library which is dynamically loaded from the main
thread of my program. I then create a worker thread in the main
program and call the functions in the library from this worker thread.
If I enable stack overflow checking in the library then whenever I
call any function in that library I get a stack overflow error. This
is because the StackBottom variable in fpc_stackcheck function is
taken from the main thread instead of the worker thread. Is this
correct or not?


My system is i386 Debian linux. I am using FPC revision 13700. I build
the library and the main program with "cthreads" unit included.

I made a sample program to show some info (attached with the mail). It
outputs several values describing current thread and the
thread-specific stack info (from rtl/inc/systemh.inc).
The worker thread has default stack size 4MB, main thread stack size
is 8MB. The main thread stack address begins with BF. , worker
thread with B7. . This is the output of the program
(checkthreadinfo.lpr):

MainThreadId  : 3077936832
< main thread, main program >
CurrentThreadId  : 3077936832
Thread ID: 3077479680
Stack ptr: BFDBFF70
Stack top: 
Stack bottom : BF5C008C
Stack length : 8388608
< main thread, library >
Libr. CurrentThreadId: 3077936832
Libr. ThreadId   : 3077479680
Libr. Stack ptr  : BFDBFF70
Libr. Stack top  : 
Libr. Stack bottom   : BF5BFC94
Libr. Stack length   : 8388608
< worker thread, main program >
CurrentThreadId  : 3076807536
Thread ID: 3076807536
Stack ptr: B7645188
Stack top: 
Stack bottom : B7245300
Stack length : 4194304
< worker thread, library >
Libr. CurrentThreadId: 3076807536
Libr. ThreadId   : 3077479680
Libr. Stack ptr  : B7645188
Libr. Stack top  : 
Libr. Stack bottom   : BF5BFC94
Libr. Stack length   : 8388608

The stack check will fail in < worker thread, library > case, because
the StackBottom is greater than current stack pointer (it is the same
value as in < main thread, library >).

If I change the program so that the worker thread loads its own
instance of the library from itself (attached as
checkthreadinfoV2.lpr) then I get the following:

MainThreadId  : 3076835008
< main thread, main program >
CurrentThreadId  : 3076835008
Thread ID: 3076377856
Stack ptr: BFFEAA40
Stack top: 
Stack bottom : BF7EAB5C
Stack length : 8388608
< main thread, library > (this library is loaded from main thread)
Libr. CurrentThreadId: 3076835008
Libr. ThreadId   : 3076377856
Libr. Stack ptr  : BFFEAA40
Libr. Stack top  : 
Libr. Stack bottom   : BF7EA764
Libr. Stack length   : 8388608
< worker thread, main program >
CurrentThreadId  : 3076283248
Thread ID: 3076283248
Stack ptr: B75C5188
Stack top: 
Stack bottom : B71C5300
Stack length : 4194304
< worker thread, library > (this library is loaded from worker thread)
Libr. CurrentThreadId: 3076283248
Libr. ThreadId   : 3076377856
Libr. Stack ptr  : B75C5188
Libr. Stack top  : 
Libr. Stack bottom   : B6DC4EAC
Libr. Stack length   : 8388608

Stack check will now not fail.

But stack length in < worker thread, library > shows 8MB, not 4MB
(which should be the thread's stack size). Does code executed in
dynamic libraries have a different stack? It seems not, because the
current stack pointer is the same in both < worker thread, main
program > and < worker thread, library >. According to the numbers the
stack for < worker thread, main program > is at B71C5300-B75C5300 and
the stack for < worker thread, library > is at B6DC4EAC-B75C4EAC. So
the addresses overlap. Is this correct? Moreover, in < worker thread,
library > the current stack pointer is outside the stack range.


An unrelated question: why there are two thread identifiers? There's
GetCurrentThreadId  in rtl/inc/thread.inc and ThreadId in
rtl/inc/systemh.inc. The CurrentThreadId is consistent - the same in
both < main thread, ... > cases, and the same in both  cases. But ThreadId in < worker thread, library > shows the same
value as in < main thread, main program > and in < main thread,
library >.

I'd be grateful for any explanations, or any pointers if I'm doing
anything wrong.

--
cobines


checkthreadinfo.lpr
Description: Binary data


checkthreadinfoV2.lpr
Description: Binary data


threadinfolib.lpr
Description: Binary data
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Debugger for the fpc available?

2009-11-07 Thread David Emerson
I used fpc for a while before starting to use Lazarus. Of course back 
then, lazarus was not as stable as it is now...

Now that I have gotten accustomed to using lazarus, I will never go 
back! Lazarus is a wonderful tool. I believe it relies upon the gnu 
debugger (gdb) although I am not at all certain-- at any rate, it 
definitely has debugging capability.

If at all possible, I'd recommend getting it installed and getting 
accustomed to it. It's highly customizable, and while perhaps not 
obvious at first, it very well may do absolutely everything you 
need/expect.

Cheers,
David.

On Sat 7 Nov 2009, Holger Bruns wrote:
> Hi,
> 
> while writing some Pascal code, I am still looking for a debugger,
> which works like the turbo debugger, in a similar way. I would love it
> to get a clue.
> 
> Best regards, Holger
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 



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


Re: [fpc-pascal] Forin Test

2009-11-07 Thread Paul Ishenin

Dariusz Mazur wrote:

with hack with trivial operator we receive the same:
 for CollectionElement in Collection.CollectionEnumerator do

yes, but it is still the hack

but what about
 for CollectionElement in Collection using TreeEnumerator do
where TreeEnumerator cant traverse thought Collection
Well,  TreeEnumerator must be a method of Collection instance to do this 
of course. If it exists then it is used.
But I have another proposition. Because we add so many variants to 
forin construction, can be added once more.

[example]
for list do 
[/example]

where we omit in keywords and iteration variable
If we ommit the 'in' keywork then it is not a 'for-in' loop, so I am not 
responsible :)


Best regards,
Paul Ishenin.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal