Re: [fpc-devel] Assigning class procedures
Peter Vreman wrote: >> Hi >> >> I'm just migrating a lot of code from delphi to objfpc mode, and I >> noticed that in objfpc mode I can't do >> >>MyFunc := @TMyClass.Func; >> >> where TMyClass.Func is a class procedure that matches the type of >> MyFunc. I'm attaching the complete source code. With >>fpc -S2 test_1.pas >> the attached code doesn't compile, fails with message >> >>Error: Incompatible types: got "> procedure(LongInt) of object;Register>" expected "> type of procedure(LongInt) of object;Register>" >> >> Tested with various FPC versions (2.0.0, 2.0.2, 2.0.3 and 2.1.1 >> (revision 2911)). >> >> With >>fpc -Sd test_1.pas >> and >>dcc test_1.pas >> it compiles OK. >> >> I initially intended to submit this as a bug, but I decided to ask here >> first. This *is* a bug, right ? I mean, delphi mode behavior seems >> sensible here, passing class procedures as procedures of objects should >> be allowed. > > Class methods require a different parameter for the implicit pushed > instance that is not compatible with normal methods. That Delphi allows it > is the uglyness of procvar typechecking in Delphi. It results in invalid > code and is therefor forbidden in objfpc. By casting the left side to a pointer it should be eaten by the compiler: pointer(MyFunc) := @TMyClass.Func; ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] TThread and heaptrc unit problem under Windows
Hi, I have problem with tThread and heaptrc unit.Look below: Summary:Exception when using TThread with heaptrc unit Description: Application using compiler options: -S2cadghi -Ciro -OG1 -TWin32 -g -gl -gh -vewnhi -l -Fud:\projekty\fpc\fcl\db\sqlite\ -Fu..\..\..\lazarus\components\tdbf\lib\i386-win32\ -Fu..\..\..\lazarus\components\sqldb\lib\i386-win32\ -Fu..\..\..\lazarus\components\sqlite\lib\i386-win32\ -Fu..\..\..\lazarus\ideintf\units\i386-win32\ -Fu..\..\..\lazarus\components\uib\source\lib\ -Fu..\..\..\lazarus\lcl\units\i386-win32\ -Fu..\..\..\lazarus\lcl\units\i386-win32\win32\ -Fu..\..\..\lazarus\packager\units\i386-win32\ -Fu. -oD:\projekty\flamenco\main\flamenco.exe -dLCL -dLCLwin32 Gives exception,stacktrace below: [FORMS.PP] ExceptionOccurred [FORMS.PP] ExceptionOccurred Marked memory at $000C51A0 invalid Wrong signature $ instead of FA030A4C $0054A5CB TRACEFREEMEM, line 580 of ../inc/heaptrc.pp $0054A881 TRACEREALLOCMEM, line 607 of ../inc/heaptrc.pp $00540631 REALLOCMEM, line 383 of D:/projekty/fpc/rtl/inc/heap.inc $0055AEDF TFPLIST__SETCAPACITY, line 61 of D:/projekty/fpc/rtl/objpas/classe s/lists.inc $00559196 TFPLIST__CLEAR, line 99 of D:/projekty/fpc/rtl/objpas/classes/list s.inc $0055CE42 TFPLIST__DESTROY, line 81 of D:/projekty/fpc/rtl/objpas/classes/li sts.inc $0053F5F9 TOBJECT__FREE, line 116 of D:/projekty/fpc/rtl/inc/objpas.inc $0054E52F FREEANDNIL, line 109 of D:/projekty/fpc/rtl/objpas/sysutils/sysuti ls.inc $00559519 TLIST__DESTROY, line 364 of D:/projekty/fpc/rtl/objpas/classes/lis ts.inc An unhandled exception occurred at $00549BAE : EInOutError : $00549BAE TRACEEXIT, line 1091 of ../inc/heaptrc.pp $00549881 HEAPTRC_finalize, line 1191 of ../inc/heaptrc.pp $00546597 FINALIZEUNITS, line 631 of D:/projekty/fpc/rtl/inc/system.inc $00543066 INTERNALEXIT, line 654 of D:/projekty/fpc/rtl/inc/system.inc $0053F1F8 DO_EXIT, line 669 of D:/projekty/fpc/rtl/inc/system.inc $0053F399 HALT, line 683 of D:/projekty/fpc/rtl/inc/system.inc $0054A6FF TRACEFREEMEMSIZE, line 467 of ../inc/heaptrc.pp $0054A5CB TRACEFREEMEM, line 580 of ../inc/heaptrc.pp $0054A881 TRACEREALLOCMEM, line 607 of ../inc/heaptrc.pp $00540631 REALLOCMEM, line 383 of D:/projekty/fpc/rtl/inc/heap.inc $0055AEDF TFPLIST__SETCAPACITY, line 61 of D:/projekty/fpc/rtl/objpas/classe s/lists.inc $00559196 TFPLIST__CLEAR, line 99 of D:/projekty/fpc/rtl/objpas/classes/list s.inc $0055CE42 TFPLIST__DESTROY, line 81 of D:/projekty/fpc/rtl/objpas/classes/li sts.inc $0053F5F9 TOBJECT__FREE, line 116 of D:/projekty/fpc/rtl/inc/objpas.inc $0054E52F FREEANDNIL, line 109 of D:/projekty/fpc/rtl/objpas/sysutils/sysuti ls.inc $00559519 TLIST__DESTROY, line 364 of D:/projekty/fpc/rtl/objpas/classes/lis ts.inc $0053F5F9 TOBJECT__FREE, line 116 of D:/projekty/fpc/rtl/inc/objpas.inc D:\projekty\flamenco\main> Any comments ? Best regards Boguslaw Brandys ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] procedure Types
You could use this: [snip] type TObjThreadFunc = function: PtrInt of object; function BeginObjThread(ThreadFunction: TObjThreadFunc): DWord; begin with TMethod(ThreadFunction) do Result := BeginThread(TThreadFunc(Code), Data); end; [/snip] 2006/3/13, Amir Aavani <[EMAIL PROTECTED]>: > > Any idea to call: > BeginThread (@MyObject.F1, Pointer (S)) > > Michael Van Canneyt wrote: > > >On Sat, 4 Mar 2006, Amir Aavani wrote: > > > > > > > >>I have problem with procedure Types. > >>Look at the following code: > >> > >>TProcedure= procedure (S: String); > >>TTest= class > >>MyF: TProcedure; > >>procedure F1 (S: String); > >>procedure F2 (S: String); > >> > >>... > >>end; > >> > >>TTest.constructor ; > >>begin > >> MyF:= @F1; > >>end; > >> > >>it says it can't cast "Procedure (S: String); Object" to TProcedure. The > >>problem is clear but I don't know > >>(can't find) any solution to define TProcedure as a procedure of a class > >>which > >>accepts one argument. > >> > >> > > > >Try the following (note the 'of object' in the declaration): > > > >Type > > TMyStringProc = procedure (S : String) of object; > > > >and then > >x > > MyF : TMyStringProc; > > > >This is documented. > > > >Michael. > >___ > >fpc-devel maillist - fpc-devel@lists.freepascal.org > >http://lists.freepascal.org/mailman/listinfo/fpc-devel > > > > > > > ___ > fpc-devel maillist - fpc-devel@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-devel > -- Geno Roupsky ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] debugging probelm
Hi! In Lazarus.when I debug a file. That is , the debugger stops and I look at the call stack, I cannot see filename and linenumber In other words, the debugging is made harder. I heard it was related to the freepascal compiler was not able to cooperate with gdb as the generated stack frame format changed... What is the timeframe in which this problem may be fixed? What debugger do you use that does not have this problem? Thanks... Márton Papp ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)
On Wednesday 15 March 2006 01:55 am, Peter Vreman wrote: > > Hello, > > > > Is there a better way to disable fpu exception other then linking to > > libc and calling fedisableexcept ??? > > Set8087CW() in system unit > SetExceptionMask() in unit math > It was for MacOsX we needed to get rid of libc, I guess Set8087CW($133F) is not CPU independant (PowerPC,x86_64), so I will use Math.SetExceptionMask([exDenormalized,exInvalidOp,exOverflow,exPrecision,exUnderflow,exZeroDivide]); I hope MacOsX is happier now (don't have one, so don't know) kind regards, Den Jean ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] blockwrite
Hello for the first time, fpc-devel group! I have posted something as bug report #4905, but didn't understand the answer (why it is not a bug). Could anyone be specific and correct source code supplied (it is especially crafted little program of 25 lines including program..., end., and empty lines). (Please, look at that source before answering, because it seems to me, that fixer didn't.) Bug report is at http://www.freepascal.org/bugs/showrec.php3?ID=4905, source example at http://www.freepascal.org/bugs/showsource.php3?ID=4905. (FP Version: 2.0.0, Win32) ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] blockwrite
On 15 Mar 2006, at 21:40, ϸòð Êîñàðåâñêèé ñ mail.ru wrote: I have posted something as bug report #4905, but didn't understand the answer (why it is not a bug). Could anyone be specific and correct source code supplied (it is especially crafted little program of 25 lines including program..., end., and empty lines). (Please, look at that source before answering, because it seems to me, that fixer didn't.) Your variable "a:^pbyte;" is not an array, it's a pointer. In Pascal, arrays and pointers are not the same thing, unlike in C. The fact that FPC allows you to abuse array notation to "index" pointers (based on the fact that TP introduced this for pchars) does not change this. So if you write blockwrite(a,..), you are passing the address of "a" to blockwrite, not the address whatever a points to. And because "b" comes right after "a" in memory, you are first seeing garbage (namely the pointer value of a) followed by the contents of "b". Jonas___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] DSO smartlinking finalization
When compiling a simple hello world DSO (dynamic link library) on linux Finalization did not occur for units in the uses clause. (testing on fpc 2.0.2) Is smart linking supposed to work on DSO's, or is it a known problem? When I tested on MS Windows, finalization did occur. Just wondering before I submit a bug report. A simple writeln call from the finalization area of a unit in the uses does not appear to work only when smart linking is on. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
RE: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)
> > Set8087CW() in system unit > > SetExceptionMask() in unit math > > > It was for MacOsX we needed to get rid of libc, > I guess Set8087CW($133F) is not CPU independant (PowerPC,x86_64), AFAIK, x86_32 will do too!! > so I will use > Math.SetExceptionMask([exDenormalized,exInvalidOp,exOverflow,e > xPrecision,exUnderflow,exZeroDivide]); I do agree it's much polite and cross platform, but doesn't seem to work in Windows XP Pro (only tested in WinXP Pro SP2) with GL 3.2 and FPC 2.0.2 (I've looked everywhere down my PC for a version number, but not found :-), I guess it oughtta be 4.1 but I can't stand for it). Anyway using Set8087CW (which is indeed CPU dependant) does work under my equipment, SetExceptionMask doesn't. > > I hope MacOsX is happier now (don't have one, so don't know) Just to make it know (as a primarily Win NT user). I really don't know whether it is as it should be or it should be fixed :-?. A plain Win user as me normally use syscalls to the API, but I'm afraid it's comprimising compatability issues. Masters will tell, I hope :-) > > kind regards, > Regards, JMR ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel