Re: [fpc-pascal] IRC channel for FreePascal support ?
On 13/04/2023 13:55, Rik van Kekem via fpc-pascal wrote: Op 13-04-2023 om 12:53 schreef Jacob Kroon via fpc-pascal: Thanks for checking, but well, I just got contacted by "Joanna" privately on IRC, this is the chatlog: The following topic might be of interest. You can view it without registering. https://forum.lazarus.freepascal.org/index.php/topic,61328.0.html There are more people who have the same problem with that IRC channel(s) and with 'Joanna'. Especially the strict rules that are enforced. (your chatlog doesn't stand alone, there are also multiple topics on the forum about this, besides the link given above.) BTW. That IRC channel is not an official FPC/Lazarus channel. (I think 'Joanna' is the founder of the channel and sole moderator there.) #fpc and #lazarus were the official channels in the freenode times. After freenode got abandoned, some active users started those channels on libera. Soon after that I registered #lazarus as the official channel for the lazarus project. No registration is done for the fpc channel (yet) As of today, Joanna is not a channel operator anymore on the lazarus channel. She has been warned that the same could happen for the fpc channel. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Open array in object constructor gives error
On 3-1-2023 14:07, Hairy Pixels via fpc-pascal wrote: On Jan 3, 2023, at 3:12 PM, Sven Barth wrote: But then you don't use the type name either. You simply do "o.Create(...)". O I get it now. I didn’t realize you couldn’t create on the type. That breaks my entire design then. It would be great to have a modern object that behaved more like classes but on the stack (like C++ does). On what instance/variable/piece of memory would your code "TMyObject.Create(['1', '2', '3'])" then operate ? Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Windows Volume Control
On 15-1-2022 19:02, James Richters via fpc-pascal wrote: Are there functions to check the current volume level and to set the volume with just FPC (not Lazarus) on Windows 10? All I need is the master system volume, not any of the mixer controls. This is possible. Please be aware that you can have multiple mixers and that the presence of the master volume is defined by the audio driver of the specific device (for a headset you may need to control the wave out). The following are more or less the routines I use. Other application logic is stripped, so it won't compile, but it should give you an idea. This code is used in a context where we can control multiple mixers, having different left/right volumes (hence the search for a specific name and a volume array) Marc function Initialize: Boolean; var n, maxlen, MixerId: Integer; woc: TWaveOutCaps; Search, Name: String; nDest: Integer; mmr: MMRESULT; mxcaps: TMixerCaps; mxl, mxlsrc: TMixerLine; mxlc: TMixerLineControls; mxc: TMixerControl; begin Result := False; // == setup volumes === MixerId := -1; // only compare the first wic.szPname -1 (==0) len characters, info.name can be longer maxlen := SizeOf(woc.szPname) - 1; Search := Trim(Copy(FName, 1, maxlen)); for n := 0 to Integer(waveOutGetNumDevs) - 1 do begin waveOutGetDevCaps(n, @woc, SizeOf(woc)); Name := Trim(woc.szPname); if not SameText(Search, Name) then Continue; mixerGetID(n, Cardinal(MixerId), MIXER_OBJECTF_WAVEOUT); Break; end; if MixerID = -1 then Exit; // === controls === mmr := mixerGetDevCaps(MixerID, @mxcaps, SizeOf(mxcaps)); if mmr <> MMSYSERR_NOERROR then begin Exit; end; if mxcaps.cDestinations = 0 then begin Exit; end; mxl.cbStruct := SizeOf(mxl); for nDest := 0 to mxcaps.cDestinations - 1 do begin // loop through the mixer destinations to find a waveout type mxl.dwDestination := nDest; mxl.dwSource := 0; mxl.dwLineID := 0; mmr := mixerGetLineInfo(MixerID, @mxl, MIXER_OBJECTF_MIXER or MIXER_GETLINEINFOF_DESTINATION); if mmr <> 0 then Continue; if mxl.Target.dwType <> MIXERLINE_TARGETTYPE_WAVEOUT then Continue; // -- master Volume -- if mxl.cControls > 0 then begin mxlc.cbStruct := SizeOf(mxlc); mxlc.dwLineID := mxl.dwLineID; mxlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME; mxlc.cControls := 1; mxlc.pamxctrl := @mxc; mxlc.cbmxctrl := SizeOf(mxc); mmr := mixerGetLineControls(MixerID, @mxlc, MIXER_OBJECTF_MIXER or MIXER_GETLINECONTROLSF_ONEBYTYPE); if mmr = MMSYSERR_NOERROR then begin // set master volume SetMixerControlVolume(MixerID, mxc, mxl.cChannels, FMasterVolume); end; end; // -- wave Volume -- if mxl.cConnections > 0 then begin mxlsrc.cbStruct := SizeOf(mxlsrc); mxlsrc.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; mxlsrc.dwLineID := 0; mmr := mixerGetLineInfo(MixerID, @mxlsrc, MIXER_OBJECTF_MIXER or MIXER_GETLINEINFOF_COMPONENTTYPE); if mmr = MMSYSERR_NOERROR then begin // get wave volume mxlc.cbStruct := SizeOf(mxlc); mxlc.dwLineID := mxlsrc.dwLineID; mxlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME; mxlc.cControls := 1; mxlc.cbmxctrl := SizeOf(mxc); mxlc.pamxctrl := @mxc; mmr := mixerGetLineControls(MixerID, @mxlc, MIXER_OBJECTF_MIXER or MIXER_GETLINECONTROLSF_ONEBYTYPE); if mmr = MMSYSERR_NOERROR then begin // set wave volume SetMixerControlVolume(MixerID, mxc, mxlsrc.cChannels, FVolume); end; end; end; Break; end; end; procedure SetMixerControlVolume(AMixerID: Integer; AControl: TMixerControl; AChannels: Cardinal; const AValues: array of Byte); var mxcd: TMixerControlDetails; idx, c: integer; detailUnsigned: array of MIXERCONTROLDETAILS_UNSIGNED; begin if AControl.cbStruct = 0 then Exit; // no volume if AControl.fdwControl and MIXERCONTROL_CONTROLF_UNIFORM <> 0 then AChannels := 1; SetLength(detailUnsigned, AChannels); mxcd.cbStruct := SizeOf(mxcd); mxcd.dwControlID := AControl.dwControlID; mxcd.cChannels := AChannels; mxcd.cMultipleItems := 0; mxcd.cbDetails := SizeOf(detailUnsigned[0]); mxcd.paDetails := @detailUnsigned[0]; mixerGetControlDetails(AMixerID, @mxcd, MIXER_GETCONTROLDETAILSF_VALUE); idx := 0; for c := 0 to AChannels - 1 do begin if idx < Length(AValues) then detailUnsigned[c].dwValue := MulDiv(AControl.Bounds.dwMaximum, AValues[idx] , 100) else detailUnsigned[c].dwValue := 0; if Length(AValues) > 1 then Inc(idx); end; mixerSetControlDetails(AMixerID, @mxcd, MIXER_SETCONTROLDETAILSF_VALUE); end; ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org
Re: [fpc-pascal] Crash on Windows for Aarch64 target
On 12-1-2022 14:37, Volo Zyko via fpc-pascal wrote: Hello, Some time ago it was announced an experimental support for Windows on Aarch64 (namely in this post https://lists.freepascal.org/pipermail/fpc-pascal/2020-April/057762.html). I tried to build a dll with a proprietary code for that target. Building succeeded but it crashes on loading. At the moment I don't understand how to investigate the issue to provide more information about it. I've been experimenting with this too. It looked cool to me to see if I can show our flagship product running on a rpi4. The major pain is to debug windbg what is going wrong on asm level. One of the issues I ran into was something weird when a case jumptable was used. It jumped to invalid code. I never was able to reproduce this in a smaller example and in the full code it was one of the issues it could run into. Now that VisualStudio starts to supports more and more dwarf debug info, I hope one day to use it as debugger. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] freepascal.org SSL_ERROR_BAD_CERT_DOMAIN
On 10-1-2022 17:45, Marc Weustink via fpc-pascal wrote: On 5-1-2022 10:15, Mattias Gaertner via fpc-pascal wrote: On Wed, 5 Jan 2022 09:40:49 +0200 "Dimitrios Chr. Ioannidis via fpc-pascal" wrote: Hi, Στις 5/1/2022 2:00 π.μ., ο/η Rainer Stratmann via fpc-pascal έγραψε: https://freepascal.org/ the certificate issued for www.freepascal.org and not for freepascal.org . It seems that the let's encrypt script was run with -d freepascal.org instead of -d *.freepascal.org . or -d freepascal.org,www.freepascal.org Better, since forum.lazarus.freepascal.org is not served by this server and has a different LE certificate. if lets encrypt registers certificates right, there cannot exist a *.freepascal.org and a different forum.lazarus.freepascal.org cert. OK, after some reading, this seems to be allowed. However while reading I noticed that *.freepascal.org doesn't cover freepascal.org. You have to define it separate Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] freepascal.org SSL_ERROR_BAD_CERT_DOMAIN
On 5-1-2022 10:15, Mattias Gaertner via fpc-pascal wrote: On Wed, 5 Jan 2022 09:40:49 +0200 "Dimitrios Chr. Ioannidis via fpc-pascal" wrote: Hi, Στις 5/1/2022 2:00 π.μ., ο/η Rainer Stratmann via fpc-pascal έγραψε: https://freepascal.org/ the certificate issued for www.freepascal.org and not for freepascal.org . It seems that the let's encrypt script was run with -d freepascal.org instead of -d *.freepascal.org . or -d freepascal.org,www.freepascal.org Better, since forum.lazarus.freepascal.org is not served by this server and has a different LE certificate. if lets encrypt registers certificates right, there cannot exist a *.freepascal.org and a different forum.lazarus.freepascal.org cert. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Lazarus server back online
Hi all, It took a bit longer than expected, but I'm happy to inform you that the Lazarus services are back online. For those interested in why it took longer, I'll explain at the end of the message. Marc On 24-12-2021 08:30, Marc Weustink wrote: Hi, On Monday 27 December 9.00 CET (8.00 GMT) the Lazarus server will be down for maintenance. This affects the following services: * Lazarus website * Lazarus mailinglists * Lazarus online package manager * Lazarus and FreePascal forum Thanks, Marc The story The server was running Ubuntu 16 LTR, so it's support ended on April this year. An attempt at that time failed since Ubuntu decided to switch to systemd-resolve which resulted in a server not even able to resolve its own name, let alone other hosts. When Googling about it, you learn that it doesn't work, it's a half backed solution, not a full DNS etc. At that time it became clear that I wouldn't be able to solve that in an evening. Luckily I could try this on a cloned server (we had to rent for another issue) so I parked the upgrade till I could spend a full day. Yesterday I found the "correct" solution to this which appeared to work. So I continued to upgrade to Ubuntu 18 and finally to Ubuntu 20 LTR. Everything seemed to work until I enabled the mailserver. It couldn't resolve any mailserver for a given domain. What the f.. 'host -t mx freepascal.org' resolves, why can't postfix resolve it. Again after some Googling, postfix needs a /etc/resolf.conf. However one step of the DNS solution was to remove the /etc/resolf.conf symlink, so I tried to restore the original link to some systemd-resolve generated one. This one pointed to their internal resolver. Still no luck since I hadn't configured systemd-resolve which DNS itself should use. After doing so, the generated resolf.conf became empty ? After more Googling I found that systemd-resolve generates another conf where you also can link to. No clue why there have to exist another version, but this one works. So this part of the server upgrade got finished around 14:00. The Lazarus mailing list and main website were back online. Another wish we had was to change the database backend of the forum. It appeared over time that when doing a search on the database, mysql blocks updates, so browsing the forum becomes unresponsive. The current version of SMF supports different databases so we decided to go for PostgreSQL (I'm using them at work for years now). Migrating MySql data to PostgreSQL seemed easy with pgLoader. The documentation about is was initially a bit sparse, but I could start a conversion with some commandline options. Unfortunately it got killed after 15 mins of import. After two more attempts it became clear, out of memory :( Reducing the memory requirements was a build time option so I didn't want to go that way. Another solution was to convert only a few tables at a time. That required however a configuration file which has more options than the command line. Most of the examples I found on the web failed, since they lack the semi colon at the end if the configuration. So the parser barfs with some abracadabra, initially not giving a clue. Fast forward, on 18:00 all but the messages table were converted. On 22:00 the messages table was converted using 9 parts. Then I realized that I didn't have a php-pgsql driver installed. After doing so, I discovered that the Lazarus main site also showed the forum maintenance message ??? Those sites are running on two different virtual servers. How can the contents of an index.php of one site have influence on the index.php of another site. What did go wrong when I installed the driver ??? After an hour investigating I decided to enable the forum first and investigate the issue later. Poof the forum results in a bunch of errors. What we didn't think of when switching backend, is that we use SMF (which is PostgreSQL capable) and TinyPortal (TP) to have the menus at the sides. And TP is full of MySQL only statements. Luckily there is someone who created all those missing functions for SMF and I created them on the database. After adjusting some TP php files (PostgreSQL requires a true boolean and not some integer <> 0), the forum started without errors. But it didn't show any boards. So there is still something wrong under the hood. Meanwhile it was 24:00 and I decided to continue using MySQL and called it a day. This morning I reverted my TP changes and put the MySQL database back online. To be continued... Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Lazarus server maintenance
Hi, On Monday 27 December 9.00 CET (8.00 GMT) the Lazarus server will be down for maintenance. This affects the following services: * Lazarus website * Lazarus mailinglists * Lazarus online package manager * Lazarus and FreePascal forum Thanks, Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to check if a network is available?
On 18-6-2021 13:49, Bo Berglund via fpc-pascal wrote: I would like to know how I can check if a remote network is available, i.e. if the VPN system has succeeded to connect the remote network. I need this in a class that connects an OpenVPN tunnel on demand and takes it down after use. Unfortunately openvpn-gui does not have an API call to do this... It provides an API for connect, disconnect, reconnect etc but not for returning the state of a connection for example. https://github.com/OpenVPN/openvpn-gui#send-commands-to-a-running-instance-of-openvpn-gui Any suggestions for Windows? I just want to know if a call to connect succeeded. You can use the management interface https://openvpn.net/community-resources/management-interface/ But since we are developers you can lookup this info with the windows function GetIpAddrTable https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getipaddrtable Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initialization of constant record member of pointer type
On 4-12-2020 13:01, LacaK via fpc-pascal wrote: Dňa 2.12.2020 o 16:09 Tomas Hajny via fpc-pascal napísal(a): On 2020-12-02 16:01, LacaK via fpc-pascal wrote: Dňa 2.12.2020 o 13:55 Tomas Hajny via fpc-pascal napísal(a): On 2020-12-01 11:39, Ladislav Karrach via fpc-pascal wrote: Because MyConst1 is not an *untyped* constant. Only untyped constants can be used in constant expressions (a pointer to something can be considered an untyped constant). The following might work though I did not test it: === code begin === const MyStr = 'abc' MyConst1: AnsiString = MyStr; MyConst2: TMyRec = (l: Length(MyStr); a: @MyConst1[1]); === code end === Yes it works, but I must define 2 constants (MyStr and MyConst1), which is not so nice ;-) It would be nice to have support for true constants: const MyConst1 = 'abc' ; MyConst2: TMyRec = (l: Length(MyConst1); a: @MyConst1[1]); But may be that there are technical reasons why it is problematic (may be that true constants are stored in another memory locations, which can not be easy addressed) Yes, that's one of possible reasons. Regarding Length in constant value assignment - remember that Length is a function. In case of real constants, the call may be replaced by the compiler with the constant value. However typed constants may not be constant, so generic replacement throughout the source code at compile time is not possible (if it appears in the main body or some function, the length may already be changed to something else) and selective replacement may result in a behaviour not expected by the user. The only questionable case is IMHO the case of {$WRITEABLECONST OFF} - the compiler _might_ be able to perform the compile-time substition in that case (and thus allow using Length of such a constant in constant value assignment), but it doesn't do that in that case either apparently. Yes I have no problem with {$WRITEABLECONST OFF} if it will allow Length(). Somewhere I read (may be in Delphi documentation) that some intristic functions like Low(), High(), Pred() and also Length() etc. can be used in constant expressions because compiler can evaluate them if theirs arguments are also constants. Which is the case in my example. For now {$WRITEABLECONST OFF} does not help ;-) Yes, that's what I mentioned as well, but it might be changed for this particular case. You might create a ticket for that if Delphi allows to use Length that way; obviously, you might create such a ticket even if Delphi doesn't allow to do that. ;-) I checked it with older Delphi XE and it seems, that Delphi XE does not support Length() for typed constant also when {$WRITEABLECONST OFF} I do not believe that this will be accepted for FPC, so I don not open new feature request in bug tracker. On other side FPC developers read this mailing list so if they consider this as a useful/doable feature may be that someone will take look at it I just happened to write a construct like this (in Delphi): const X_0: array[0..4276] of SmallInt = (. MAP: array['0'..'9'] of TSomething = ( (Samples: @X_0; Count: Length(X_0)), ... Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit
On 12-5-2020 14:56, Marco van de Voort wrote: Op 2020-05-12 om 12:32 schreef Michael Van Canneyt: The names I use here are the libc names, which many other languages also use. Now, StrToHostAddr and StrToHostAddr6 can call the appropriate function, and programs that use those functions won't notice any change. But new code will be able to use the new functions and have an unambiguous answer as to whether the address is valid or not. The change is quite straightforward to make, and it won't break existing code, so I think it's worthwhile to do. Any thoughts or opinions on this? I'm all for it, but please use the following names: function TryStrToHostAddr(IP: String; var ip4: in_addr): Boolean; function TryStrToHostAddr6(IP: String; var ip6: in6_addr): Boolean; Rationale for this request: All conversion calls in sysutils and dateutils use this naming scheme, it's good for consistency. (and I hate underscores, but that's beside the point ;)) Yes to the principle and yes to the TryStrTo naming. But I would make the IP param CONST ;-) And maybe change the var into an out Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Freepascal/Lazarus forum and Lazarus website outage wrap-up
Now that everything seems to be normal, time for a wrap-up, what happened: There were happening 2 things simultaneously - an increased interest(?) from china - one or two bots every second looking for SQL injections. This caused a load on the original server configuration, apache using mod_php, so it became unresponsive. Since the amount of traffic was larger than normal, but still realistic, I decided to use fast-cgi to remove the php overhead from the apache main process. With fast-cgi in place I could now use the mpm_event module which can handle way more connections to the server. After some days of config tweaking everything should be fine. not. The server started to work OK until, according to netstat, about 800 sockets were in use, after which the server failed to respond. This continued till the amount of sockets dropped to about 50 (due to timeouts etc). Then the server was responsive again and the whole cycle started over again. After a lot of googling it appeared that this was caused by this issue in apache https://bz.apache.org/bugzilla/show_bug.cgi?id=53555 A manual upgrade of apache to the latest version solved the problem. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] OT: what happened with the Lazarus mailing list?
On 25-11-2017 09:29, Lubos Pintes wrote: Hello, I don't know if the problem is somewhere on my side, but the latest message in Lazarus mailing list on gmane.org is from November 17. I also looked into web archive and the situation is the same. And I am unable to find more information about what happened. Also tried to subscribe, but no reply from the server. So what happened? Somehow mailman refused to distribute the mails. After a reboot is picked up its task :) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] New feature: IfThen() intrinsic
Sven Barth wrote: Am 01.02.2016 09:26 schrieb "Maciej Izak">: > > 2016-02-01 8:59 GMT+01:00 Marco van de Voort >: >> >> The only really bad thing is the name, as Florian already said, with the >> versions in strutils and math. The clash with delphi compatible functions >> should be avoided. > > > +1 . IfThen instricit is IMO very bad idea. I have a lot of "IfThen" from math and strutils modules. > > IfThen from System totally breaks the compatibility :\ . C'mon Sven. In one field you're rigorously but in something like this you're liberal (braking/dangerous change / for existing code base). It does *not* break existing code at all. It will break future code. What if I need math someday and add this to the uses clause ? Which one will be called ? I have to admit though that I forgot about the potential problems due to refactoring. I'll change the name to avoid this pitfall, though I've yet to decide which one. OK, Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] File Descriptor in Windows ?
fredvs wrote: Hello. Sorry to sorry to bother you with that file descriptors again... ;-( There are some answers there on mpg123 forum. They explain that simple stdin/stdout file descriptors would work. Of course all what they explained is in C ;-( OK, but how can i use simple stdin/stdout file descriptors in Pascal ? What is the code to retrieve that stdin/stdout file descriptors in Windows? What in unix is used as filedescriptor is in general in windows used as handle (filehandle/sockethandle) Googling for windows msdn stdin resulted in: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683231%28v=vs.85%29.aspx I've no clue why a lib should need this (and if a non console app would have any) BTW, back to your original question, I looked at the docs for mpg123_open_fd() but it absolutely clueless about the second argument Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpc in symlinked directory
Michael Van Canneyt wrote: On Wed, 26 Mar 2014, Mattias Gaertner wrote: On Wed, 26 Mar 2014 15:33:38 +0100 (CET) Michael Van Canneyt mich...@freepascal.org wrote: [...] So ? You just need to check the inode. Is there a function to list all files pointing to an inode? Actually, you just need to know if 2 filenames point to the same inode. And what 2 files should I check? There are thousands of files in the search path. To avoid duplicates, only the files that are already open in the IDE must be checked. For the others, it is irrelevant how you opened them. There are 2 scenarios: 1. A file with a similar name (filename part matches) is already open in the IDE. If you collect the inode when opening, there is no problem (I'm guessing you already do a stat on open. 2. No such file is opened: You can open it using whatever path. The next time a file must be opened, you check the file at the 'locical' location, and if its inode matches an opened file, you know it is open already. This will fail if the file is located on some smb or nfs mount. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Feature proposal: function-based assignment operators
On 28-3-2013 17:52, Jonas Maebe wrote: += does *not* prevent re-evaluating the left side. It is internally translated to x:=x+y and then evaluated like normal. So if x contains a function call with side effects, these side effects are still triggered twice. Is evaluated as x := x + y or as x := x + (y) (where Y can be any expression) I usually tanslate C code like the first, but recently found out that is should be done like the last. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 2D Dynamic arrays and BlockRead
On 3-12-2010 17:26, Jürgen Hestermann wrote: andrew.benn...@ns.sympatico.ca schrieb: After using BlockRead to fill a 2D dynamic array, I get an access violation on the very first reference. A 2D array with only one dimension dynamic works OK. What am I missing? Maybe you blundered into the same trap as so many others who do not know that dynamic arrays are *pointers* (to arrays). It is one of the sins done by Borland to abandon the once strict logic that in Pascal the syntax is always context independend. Now this is no longer the case (i.e. for dynamic arrays). in your example STat = Array[0..W-1] Of Single ; { Static array } DST = Array Of STat ; { One dimension dynamic, the other static } D2T = Array Of Array Of Single ; { Two dynamic dimensions } STat always means the address starting with STat[0] (context independend). Also DST always means the address where DST[0]. Nope, there is a difference between DST and DST[0]. DST won't give you the first element. You can try this youself with an untyped parameter: procedure Foo(const AParam); begin WriteLN(Single(APAram)); end; You will see a difference between passing DST or DST[0] To be safe, for any N-dimension dynamic array always use [0,..,0] to pass the first element. To avoid confusion, you can do this for static arrays too. But D2T is a pointer which can be either the the address of the pointer (in all low level routines like fillchar, sizeof, BlockRead/-Write etc.) but also can be the address of the D2T[0] because you can refer to elements without the need to dereference it as in D2T^[0]. In behaviour DST and D2T wont differ. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Extended, Currency and TDateTime memory layout
Felipe Monteiro de Carvalho wrote: On Fri, Aug 6, 2010 at 4:52 PM, Michael Van Canneyt mich...@freepascal.org wrote: Strange, because tkCurrency exists ? A currency is a Int64, which is the currency amount multiplied by 1. Well, apparently Delphi 6 RTTI thinks that it is a float. Check this code: A currency being a float type makes some sense. IIRC the Comp type was used to represent currency, a fixed point number with 5 decimals. This Comp type was defined and calculated in the numeric coprocessor (like all other floatingpoint types) Therefore older versions of Delphi see this as float (iirc) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] a few trivial questions
Jürgen Hestermann wrote: I personally hate 0-based counting because no human counts 0, 1, 2 etc.. so why must computers? Yes. That's my feeling too. Zero-based arrays/lists always generate trouble because of substracting or adding one in many places. It makes code much less readable. Read Index as offset form start. Then the index 0 makse some sense for the first element :) But because 0-based is so standardized in programming languages, Well, it is mainly C that has this standardization. In Pascal this was never a standard. it's just easier to follow the crowd than fight them. :-) In the first place it is. But if it would be available, the crowd may change its mind. IIRC indexes in VB were 1 based, didn't change much Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TAP-Win32
Felipe Monteiro de Carvalho wrote: What does TAP stand for? see http://en.wikipedia.org/wiki/TUN/TAP for some pointers. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] newbie questions
spir ☣ wrote: On Tue, 20 Apr 2010 01:17:51 +0200 Marc Weustink m...@dommelstein.net wrote: Somehow I get the idea that you mix the definition/use of sets with arrays. Yes, it seems Pascal sets are rather related to enums than collections. I mean they look like packs of kinds of flags, which themselves are named but value-free indicators. If I'm right, enums are sequences of such flags. Correct. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] newbie questions
spir ☣ wrote: Hello, Total Pascal newbie here. Looked for answers in various references and tutorials, but cannot find. Fore-question: Is there a (free)pascal teaching/learning mailing list? (Like python's tutor list.) If not, is this one a proper place? * How does one declare the type of set items? numbers : Set of Integer // error A set can only have 256 elements, in you case that would have been 4G elements. So the max is TByteSet = set of Byte; but usually a set (or enum) is given a reable name like TMyEnum = (one, two, three); TMySet = set of TMyEnum; * How does one define the _value_ of a Set or Array? numbers := (1,2,3) // error numbers := [1,2,3] // error const Numbers: array[0..3] of integer = (1, 2, 3, 4); MySet: TMySet = [one, three]; Somehow I get the idea that you mix the definition/use of sets with arrays. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Lazarus Snapshots Intel Mac with FPC 2.4.1?
Jonas Maebe wrote: On 19 Apr 2010, at 16:15, Tobias Giesen wrote: This usually means that they were compiled by a previous compiler, or that they use units which have been changed and recompiled since the previous compilation. In that case, the compiler will ignore the precompiled unit and try to recompile it. If it then doesn't find the sources, you'll get an error about the unit not being found. Yes but the sources were there. They were in the search path, but the compiler didn't search properly. I will look into it again and if there are bugs, I will fix them in the FPC sources and submit the fixes. If you have such problems in the future, compile with -vut and the compiler will show where and what it searches, andwhy it refuses certain units or recompiles them. (Recompiling XYZ.pas because the checksum changed although it didn't). I deleted all .o and .ppu files and still this happened. I'm not mixing anything. The problem is that FPC sometimes doesn't like its own units - maybe because of different compiler switches? In some cases, the compiler will want to immediately recompile previously compiled units: a) if you use a unit that has in its interface section a procedure that is declared normally, but which is declared as external. Solution: declare it immediately as external in the interface and remove the version in the implementation b) if you have inline procedures in the interface of unit1 and a unit that uses unit1 is (indirectly) used in the implementation of unit1. Solution: compile everything with -Ur (= create release units; the compiler will never try to recompile such units afterwards, except if the interface section of a unit that it uses has been changed and this other unit has been recompiled). Another, more seldom reason for recompilation problems is that you happen to name one of your own units the same as a rtl/fcl/lcl library unit. In that case the compiler thinks that your file is the new source and it wants to recompile the library units Like Jonas said, you will find this when compiling with -vut Solution, rename your unit. (happend once to me with some obscure unit, and took some time to figure out) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Published - Public
Martin wrote: procedure TChild.Foo; begin inherited; // or: inerithed Foo; // do more end; I thought that in this last case, the compiler would know, that inherited points to TBase.Foo; and the compiler would optimize the code, to call directly (skipping the VMT) ? But I guess I am wrong about that? OR how else could the above work? Your correct, thats why toyu are not allowed to use inherited in these classes, but procedure TChild.Foo; begin TBaseClass(ClassParent).Foo; // do more end; Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Published - Public
Flávio Etrusco wrote: On Fri, Apr 16, 2010 at 4:54 PM, José Mejuto joshy...@gmail.com wrote: Hello FPC-Pascal, Friday, April 16, 2010, 9:06:45 PM, you wrote: FE Published methods can be found with TObject.MethodAddress, that's how FE the lfm hook event handlers (and why Form event handlers are FE published). Yes, but thats for streamable objects like TForm, or any component, but I think that that's not the case of TWS objects which are the widgetset interface, and also all of them are class procedure. Marc says in Lazarus that a virtual class tree is formed with such published methods, I do not know the need of it or the mission, but if it is OK it is OK ;) for me. -- Best regards, José Sure, I was just saying that in a different context. I found Marc's observation very weird, and I'm (still) going to check it. Its not my observation, but my implementations :) Imagine the following base widgetdset tree (best viewed with a fixed font) TWSBase | + TWSWinControl | | | + TWSButton | + TWSSomeOther Now we have a widgetset, say XXX, implementing these classes when you use the normal inheritence you get a tree like: TWSBase - TWSXXXBase | + TWSWinControl - TWSXXXWinControl | | | + TWSButton - TWSXXXButton | + TWSSomeOther - TWSXXXSomeOther Now you see a problem here. You would expect TWSXXXButton to be derived from TWSXXXWinControl, but it isn't, so it doesn't have the TWSXXXWinControl implementation. Now comes the vitrual class tree lazarus uses. Based on RTTI it creates its own VMT tables, rewriting the tree to: TWSBase | + TWSXXXBase | + TWSWinControl | | | + TWSXXXWinControl | | | + TWSButton || |+ TWSXXXButton | + TWSSomeOther | + TWSXXXSomeOther Now TWSXXXButton is derived from TWSXXXWinControl Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Implementing an interface force me to add _AddRef, _Release
Zaher Dirkey wrote: On Thu, Apr 15, 2010 at 11:09 AM, Michael Van Canneyt mich...@freepascal.org wrote: {$INTERFACES CORBA} {$INTERFACES CORBA} It is resolved my problem, Is there any limit to use it (except it is not work in Delphi)? You cannot use casts like var a: IMyObject; b: IMyOtherObject; begin b := a as IMyOtherObject; or functions like supports() (which uses queryinterface) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Published - Public
José Mejuto wrote: Hello FPC-Pascal, If I have a class like: TMyClassPublished=class(TObject) published procedure MyProcedure; virtual; end; And a derived one: TMyClassDerived=class(TMyClassPublished) public procedure MyProcedure; override; end; Is there any difference in the derived one with less visibility in the method ? This means, does it use less/more memory, more/less calling speed, more/less RTTI information, ... ? no, no, no, no You cannot lower visibility, since the following example is still possible: var a:TMyClassPublished; begin a := TMyClassDerived.Create; a.MyProcedure; end; it will use the scope of a and not the redefined scope in TMyClassDerived Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] constructor as procvar
David Emerson wrote: How can I obtain a class type variable from an instance? I want to create a second instance of the same descendant class (via the constructor, which will take some parameters and make the new instance unique) Tobject.classtype returns TClass (class of TObject) which I first assumed would work great. However I cannot seem to do a type conversion from TClass to t_mammal_class (class of t_mammal)! So I am stuck here. IIRC you can do t_mammal_class(my_mammal.ClassType).Create Marc I tried just using TClass and skipping t_mammal_class, but then I can't use my overriden constructor that takes special parameters. Thanks in advance, David. On Fri 19 Mar 2010, David Emerson wrote: Florian Klaempfl wrote: Constructor procvars are indeed not supported but the way to achieve what you want is to use class type variables t_mammal_class = class of t_mammal; function find_or_create_animal (color : byte; pass_mammal_type : t_mammal_class) : t_mammal; brown_pig := t_pig (pig_pen.find_or_create_animal (brown, t_pig)); ah, that is exactly what I need. Works perfectly. Thanks much. ~D. ___ 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 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: FPC from subversion without root access
Osvaldo Filho wrote: Thank you. I have my own compiler - files from another computer - not the ubuntu package. How can I say the Make program where are the files of the compiler? They are in: ~/apps/fpc/bin and ~/apps/fpc/lib add ~/apps/fpc/bin to your path ( if you use bash: add the following to your ~/.bach_profile PATH=$HOME/apps/fpc/bin;$PATH ) and add the following lines to your ~/.fpc.cfg -Fu~/apps/fpc/lib/fpc/$fpcversion/units/$fpctarget -Fu~/apps/fpc/lib/fpc/$fpcversion/units/$fpctarget/* -Fu~/apps/fpc/lib/fpc/$fpcversion/units/$fpctarget/rtl if you don't have a ~/.fpc.cfg and do have a /etc/fpc.cfg you can add the following as first to your new ~/.fpc.cfg #INCLUDE /etc/fpc.cfg Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: FPC from subversion without root access
Osvaldo Filho wrote: Sorry: How can I get the FPC subversion installed on my directory? 1) Download form subversion - Ok download them into say ~/fpc/trunk ...) Compile? Create ~/.fpc.cfg? How ? then in ~/fpc/trunk dir run: make all make install PREFIX=~ FPC_VERSION=2.5.1 this will install the compiler in ~/bin ~/lib etc then edit ~/.fpc.cfg and add or adjust paths so they point to ~/lib/fpc and make a symlink in ~/bin: ln -s ../lib/fpc/2.5.1/ppc386 Marc Em 18 de fevereiro de 2010 19:36, Osvaldo Filho arquivos...@gmail.com escreveu: Como posso ter o FPC do subversion instalado em meu diretório? 1) Download form subversion - Ok ...) Compile? Create ~/.fpc.cfg? How ? ___ 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] FPC class syntax was extended to support delphi code
Paul Ishenin wrote: David Emerson wrote: d. What happens with inheritance? d.1. wrt class constants and class vars-- are there separate instances (for lack of a better word) of these, one instance for each descendant? Or is the class var/const only stored once for the ancestor that declares it, and all descendants share that? Class vars (static class fields) are stored only once for the class which declares them and all descendants share that. Example: TSomeClass = class class var Value: Integer; end; TDescendant = class(TSomeClass); begin TSomeClass.Value := 1; TDescendant.Value := 2; WriteLn(TSomeClass.Value); // this must output 2 end; Class static field is not a new feature. But now you can declare them using 'class var' section after methods or 'type'/'const' section. Can we have a virtual version too like described here http://hallvards.blogspot.com/2007/05/hack17-virtual-class-variables-part-i.html Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] RE: Possibly a dumb question.... (Jennifer Usher)
Graeme Geldenhuys wrote: 2009/12/28 Vincent Snijders vsnijd...@vodafonevast.nl: It is a bug ans should save that file automatically. And the bug seems to be Windows specific. It works perfectly under Linux, by automatically saving in the /tmp directory. Linux has no manifest :) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Forum merger
dmitry boyarintsev wrote: I'm not sure if forums are to be merged or not, but why not to start an FPC specific thread on Lazarus forum? For example there're a lot of RTL/FCL specific subject, like this one: http://forum.lazarus.freepascal.org/index.php/topic,8272.msg39707/topicseen.html#new The subject is not LCL related nor ideas, though located under: Suggestion/Ideas - LCL. I wonder if it's possible to create a root thread FreePascal - General or Using FreePascal - General (or more specific - Bugs / Patches) I see no problem in adding Freepascal / Compiler General Rtl Packages (and maybe move databases) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problem compiling DLL for 64Bit Windows - complete example attached
Lukas Gradl wrote: Hi! I'm having serious troubles compiling a DLL for 64bit Windows. I'm using FPC svn 1 (Ver 2.5.1) on all machines. I tried on WinXP 32bit (works), Vista 64bit (doesn't work), Win7 32Bit (works) and Win7 64bit (doesn't work). rMonitor=packed record ... end; rMonitorEx=packed record dwMonitorSize:DWORD; Monitor:rMonitor; end; Are you sure the C record is packed too ? This would mean that all function pointers in rMonitor are not aligned. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Forum merger
Bee Jay wrote: We have already merged the wikis, what about merging the forums? I would propose merging into the Lazarus forum. Why don't we make our own forum application using fpWeb (or Powtils or ExtPascal)? Specially dedicated for FPC and Lazarus users. It can be a showcase that pascal (FPC/Lazarus in this case) also can be used to build a web application. If we're so proud that our compiler can compile itself, why don't we create our own forum? ;) This might be the right moment. History is repeating. When we planned to move the lazarus forum the same discussion was started. It took months without result. Building a proper forum is not something you do in a few days. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] one question FPC
Lidia Stanganelli wrote: Hello, I have a program in Pascal that compiles correctly on windows 32-bit but when I compile on windows 64-bit give me the following errors: Compiling C:\Users\workspacepascal\webutil.pp aamod_elearning.pas(27,38) Error: Identifier not found CONF_FILE Windows 64-bit I user FPC 2.2.4. Does anyone help me? Where is CONF_FILE declared when using win32 ? in the fpc sources I only find it in mysql.inc, mysql4_comdyn.pp and mysql4_com.pp used as procedure parameter. In those cases I see no dependency on win32 or win64 Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Why use pointers to arrays?
Graeme Geldenhuys wrote: On 11/10/2009, Andrew Brunner andrew.t.brun...@gmail.com wrote: FPC forces the ^ operator while accessing structures as pointers. Delphi didn't force it and I even suspect that memory leaks can result in NOT using the ^ to denote the reference to the pointer rather than the pointer itself. This was just discussed in another thread. This is not always forced by FPC. eg: var S: TMyArray; pS: ^TMyArray; then use them as follows: S[2] pS[2] Both work just fine without dereferencing the second line. Weird behaviour, but true. However they have a different meaning. assume TMyArray=array[1..10] of Byte; then S[2] refers to the second element of S, being the second byte, while pS[2] refers to the 3 element of pS, being the 3rd TMyArray Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] object.ClassInfo.Create
Martin wrote: Just got a question, to ensure I understand thinks correctly. Let's start with stuff I definitely know (or think so). Destructors are virtual/overriden, because they are called on the instance, and the instance may be assigned to a variable foo: Tobject, which would call TObject.Destroy instead of TMyClass.Destroy. Constructors don't (usually) need this, because the are (usually) called on a class (that is the classname usually appears hardcoded in the source) on TComponent constructors are virtual, because when loading from resource, those objects are instantiated separately (with NewInstance() ), and the constructor is called on an instance. So nothing new, the usual way of virtual methods It's not only for streaming, there are more common cases where you might need virtual constructors: var GraphicClass: TGraphicClass; Graphic: TGraphic; begin case Something of 1: GraphicClass := TBitmap; 2: GraphicClass := TPNGImage; ... end; Graphic := GraphicClass.Create; ... end; Now if I have a variable/value with classinfo? AnyObject.ClassInfo = has the class info for it's class BUT TMyClass.Classinfo, could either be a TmyClass or a TMySubClass (and per definition ClassInfo is TObject, and could be anything inherited from Tbject) Correct. SO if I wrote FMyClass := AMyClass.Classinfo.Create; What will actually happen? It creates an instance of your class, but calls TObject.Create If I understand this right, an instance of TMyClass (or TMySubClass , if AMyClass was a TMySubClass) is created; BUT the constructor TObject.Create is called (with then TMyClass instance) ? And it would skip any constructor that was on TMyclass? Correct. Then I could of course write TMyClassType = class of TMyClass; FMyClass := TMyClassType (AMyClass.Classinfo).Create; and it would call TMyClass.Create. And if TMyClass wanted to have it's own constructor, the TMyClass.Create must be virtual? No, you don't need a virtual constructor here yet, since the TMyClass.Create will be called. However if you have TMySubClass too with an own create, you need one. How close am I do the truth? Close :) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] compiling lazarus : custombitmap.inc(293, 49) Error: absolute can only be associated with a var or const
Benedikt Schindler wrote: Hi, when i try to compile lazarus i get a error message absolute can only be associated with a var or const did someone have an idea why this happens? You need either a svn version of Lazarus or a compiler 2.3.1 see r12878 Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] PWideChar vs. ^
Marc Santhoff wrote: Hi, maybe this is a dumb question, but: If I have a variable declared as var s: PWideString; why is an exception (AV) thrown when using something := s^; but not when using something := PWideChar(s); ? You're mixing things up. A Widestring is a dynamically allocated type which holds wide chars. So when declaring var W: Widestring; you are under the hood in fact declaring a pointer to a dynamically allocated (referencecounted on non windows) struct holding the string. What you declare is a pointer to this var S: PWideString; Like a variable of a PChar type this pointer doesn't contain anything but random noise, unless you initialized it. When you assign something := s^; you are dereferencing random data, which in most cases cause an AV. (even worse in this case since you assume this random data is a pointer to a widestring) When you cast and assign something := PWideChar(s); you treat this random pointer as a pointer to widechars. If you are lucky you are allowed to read this data and it is somewhere #0#0 termintated, so that is can be intrepreted and converted to a something. Maybe this is special behaviour of the routine getting the variable, it is TTreeView.AddChild(ParentNode: TTreeNode; const s: string): TTreeNode I guess this is not the same S Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] My favourite missing feature
Mark Morgan Lloyd wrote: There seem to be a number of people currently making outrageous suggestions about missing features or how FPC could best be repackaged and promoted, so since it's the season of good will I trust that folk will tolerate this one from me. There's been a recent thread in fpc-other on second languages, but it appeared to focus more on what was a useful part of a developer's skillset rather than what people miss from Pascal. What /I/ miss is Perl's pattern matching, and I miss it to the extent that in some of my own scripting stuff I've implemented it myself: IF cells[2, dateTime] = /(\d\d)\/(\d\d)\/((\d\d)?\d\d)\s.*/i THEN BEGIN and now in plain english, what does it match ? Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Array [THandle] of pointer
Andrew Brunner wrote: Following Setup: Ubuntu 8.10 x64 FPC 2.2.3 (latest and greatest) Lazarus (Latest and greatest) I'm seeing an anomaly with reading/writing to an Array[THandle] of Pointers. TMyStruct=record Index:integer; end; PMyStruct=^TMyStruct; TMyList = Array[THandle] of PMyStruct; If I declare a localized variable procedure Test(); var MyTest:TMyList; hThread:THandle; begin hThread:=getCurrentThreadID; if (MyTest[hThread])=nil then begin // CRASH HERE EXTERNAL SIGBUS end; end; This should not crash here. It should have been nil. Any work being done in this area or should I report another bug? I'm surprised it crashes there. A THandle is IIRC a Cardinal on unix, so by defining a variable MyTest:TMyList, you allocate 4GB * SizeOf(TMyStruct) = 16GB on your stack. Usually a process doens't have that much space and I wonder if you wanted this. (You may want to look at the lcl Maps unit) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] My favourite missing feature
Mattias Gaertner wrote: On Wed, 24 Dec 2008 01:41:16 +0200 ik ido...@gmail.com wrote: It looks for a date pattern like the follow 10/10/08 and 10/10/2008 with space and then some other chars as well. I think if it was with boundaries of begin and/or end (^ and $) it would work even better. The () indicates groups. each group is the string extracted from the pattern, and can be used (that's the /1/ and /2/ that he wrote). This entire thingy called regular expression or regex for short. Ido On Wed, Dec 24, 2008 at 1:17 AM, Marc Weustink m...@dommelstein.net wrote: Mark Morgan Lloyd wrote: There seem to be a number of people currently making outrageous suggestions about missing features or how FPC could best be repackaged and promoted, so since it's the season of good will I trust that folk will tolerate this one from me. There's been a recent thread in fpc-other on second languages, but it appeared to focus more on what was a useful part of a developer's skillset rather than what people miss from Pascal. What /I/ miss is Perl's pattern matching, and I miss it to the extent that in some of my own scripting stuff I've implemented it myself: IF cells[2, dateTime] = /(\d\d)\/(\d\d)\/((\d\d)?\d\d)\s.*/i THEN BEGIN and now in plain english, what does it match ? see also http://wiki.lazarus.freepascal.org/IDE_regular_expressions I know what regular expressions are, I know that when you are writing them, you understand what you wanted to do, but 5 mins later you don't know anymore what it meant, let alone how to debug. (no it wasn't a serious question) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] number of cpu cores
Mattias Gaertner wrote: At the moment I have the attached function. It returns only 4 on a 2 x quad core Mac. Maybe someone can test under windows? returns 4 on a quadcore xp64 Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpImage resample via interpolation
Mattias Gaertner wrote: On Fri, 28 Nov 2008 15:45:08 +0100 Vinzent Höfler [EMAIL PROTECTED] wrote: Von: Mattias Gärtner [EMAIL PROTECTED] I'm curious: who needs more than 13 different image interpolations? 13 different users, of course. ;) That was a rhetorical question, wasn't it? Not completely. ;) I don't doubt the need of 13 different interpolations. I know most of the interpolations from other graphical/mathematical applications. But I doubt the need for 13 different *image* interpolations. My question is if they exist in fpimage only, because they were easy to implement, or are they all that different that you need them? I think speed vs. quality if you have multiple steps. While playing with aggpas, I found that the image1 example gives a nice idea about the differences: http://aggpas.org/aggpas-demo.htm Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Debugger interaction in FP IDE and Lazarus
leledumbo wrote: Peter Vreman wrote: The idea to implement this and reuse some Lazarus code has been around for a couple of years. But it is not an easy task after a couple of quick investigations. That is also the reason why it has not been started yet. You are welcome to implement such an interface and remove the libgdb dependency. Before I start something stupid, can you describe the result of that quick investigation? Initially the lazarus interface to GDB was visual component free (no LCL controls). In time some some got added. IIRC, mostly dialogs. If those get changed to a notify event that part is cleaned. IIRC there was another issue. That is that the FP ide is object based and the lazarus interface class based. (I never looked at the fpide code, so I'm not sure here) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
Micha Nelissen wrote: Mattias Gärtner wrote: How to translate this: struct a; Isn't this a forward declaration? So sometime later it needs to declare 'struct a { ... };' ? If not, can't it be translated as: a: record end; ? Marc (not a Cist) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Article writers wanted.
Hi, recently I spoke to Detlef Overbeek, editor of the Blaise Pascal magazine (http://blaisepascal.eu) and he asked me if there would be people interested in writing an atricle about Freepascal or Lazarus or combination of both. Since i'm not that big writer, i'll aks it here too. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: Summary on Re: [fpc-pascal] Unicode file routines proposal
Florian Klaempfl wrote: [..some of my thoughts..] this suits a construct I saw somewhere: type SomeString = type String(CP_KOI8); Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Unicode file routines proposal
Martin Schreiber wrote: On Tuesday 01 July 2008 18.32:30 Mattias Gärtner wrote: In this routines length(widestring), widestring[index], pwidechar^, pwidechar[index], pwidechar + offset, pwidechar - pwidechar and inc(pwidechar)/dec(pwidechar) are used often. This can't be done with utf-8 strings. Ehm, do you know, that UTF-8 has the advantage, that many ascii functions work without change? For example ReplaceChar or searching a substring? Sure, but for layout calculation and the like we need fast access to codepoints. The only way to be sure is using utf-32 in this case. (or not supporting unicode) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pointers in Pascal!!
Mattias Gaertner wrote: On Wed, 30 Apr 2008 01:22:47 +0200 Marc Weustink [EMAIL PROTECTED] wrote: Alan Krause wrote: Hans Mårtensson wrote: But that would not work after the pointer was used and then it's memory freed. So a better way might be: Always when declaring pointers do it this way: var p: ^sometype = nil; Then in stead of using the freemem, define your own procedure: procedure myfreemem(var p: pointer); begin if pnil then begin freemem(p); p:=nil end end; Use FreeAndNil() - http://www.delphibasics.co.uk/RTL.asp?Name=FreeAndNil FreeAndNil works only for classes, not for objects/record ReAllocMem(p,0); Ah, now I understand why you use them :) Anyway does it set p:=nil ? Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pointers in Pascal!!
Alan Krause wrote: Hans Mårtensson wrote: But that would not work after the pointer was used and then it's memory freed. So a better way might be: Always when declaring pointers do it this way: var p: ^sometype = nil; Then in stead of using the freemem, define your own procedure: procedure myfreemem(var p: pointer); begin if pnil then begin freemem(p); p:=nil end end; Use FreeAndNil() - http://www.delphibasics.co.uk/RTL.asp?Name=FreeAndNil FreeAndNil works only for classes, not for objects/record Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pascal postscript reading library
Felipe Monteiro de Carvalho wrote: On Wed, Apr 23, 2008 at 4:32 AM, Krishna [EMAIL PROTECTED] wrote: Hmm... vague your mail is. What kinda interpretation? If all you want is to slurp the text then it might be possible but then Postscript is a full blown programming language and people (mostly) come up with their own operators for showing text... Ok, I think it's time to explain a little bit more in detail what I am trying to do. I am building a CNC Machine. It's like a 3D printer, it can cut into wood and metal and build objects, or generate drawings (not with ink, but through cutting) into existing objects. The drawing will most likely come from CorelDraw. We are developing a printer driver which will then use a ready made virtual printer which is able to generate postscript as output, which will make our driver very simple to build. I could read the CorelDraw files directly, but I'd rather not be stuck to 1 drawing software, and CorelDraw may change their files in the future, but postscript is likely to remain stable. So at this point I need to convert postscript into Machine commands, i.e. move to start position, start drilling, move X, Y, move again, etc ... end. I don't need to parse everything from postscript, just the absolute minimum to extract the vectorial drawing coordinates, start point and end point. I am a little impressed that everyone says postscript is so complex, so I'm reevaluating which path to go, but I do have a competent software developer available to whom send the task, so the amount of work isn't that much a problem =P (as long as it is doable by 1 person in a couple of months) Interpreting postcript is doable, but postscript contains way more info than you need. If it is just moveto and lineto you need, you may want to consider using a HPGL plotter driver. HPGL is a textual language used for plotters. It consists mostly of commands like: get pen, move to, line to (and a few others I forgot) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Trim db-fieldnames, or not?
Graeme Geldenhuys wrote: Marc Weustink wrote: with quoted identifiers you can do whatever you want. One of the examples I use why you don't want to use them is: SELECT select FROM from WHERE where and and BETWEEN between and and HAVING having ORDER BY order by hehehe... I don't use quoted identifiers either. That example belongs on the what the fuck website [http://thedailywtf.com], aka worse than failure! :-) :) They only have production code, this is an example I use :) I haven't seen this in production yet (other wtfs I did see though) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Trim db-fieldnames, or not?
Graeme Geldenhuys wrote: On 19/04/2008, Michael Van Canneyt [EMAIL PROTECTED] wrote: That is just sick! It is. Courtesy of MS-Access users... That was the first to support it, AFAIK. (although access uses [] instead of , as far as I remember) That's is sick! And yes, MS-Access uses the square brackets. with quoted identifiers you can do whatever you want. One of the examples I use why you don't want to use them is: SELECT select FROM from WHERE where and and BETWEEN between and and HAVING having ORDER BY order by Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] connection problem
JoshyFun wrote: Hello Jesus, Saturday, March 29, 2008, 7:19:34 PM, you wrote: JRA For fpc repository I use JRA http://svn.freepascal.org/svn/fpc/trunk and it JRA doesn't work anyway, I don't get the PROPFIND problem though, after I type JRA svn update, the command doesn't do anything. From my side it looks like a transparent proxy problem, so setting an alternative port different then 80 may help. Maybe somebody that can successfully access should dump the received http headers, maybe one of them is confusing the transparent proxy :-? We used to have port 8080 for this on svn. Don't know if this got reinstalled after the last change. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
Daniël Mantione wrote: Op Tue, 5 Feb 2008, schreef Luiz Americo Pereira Camara: can i safely use the below object instead of the record and pass directly to the c function? TMyObj = object x: Integer; y: Integer; Method1; Method2; end; PMyObj = ^TMyObj; Yes, objects (by specification) are defined to have the same binary layout as records. Moreover, whats the difference between objects and records with methods (the new Delphi feature)? Objects can have virtual methods, constructors, destructors. The new Delphi feature cannot. however with virtuals or constructors/destructors, the memory layout is not 100% the same as a record. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
Vinzent Hoefler wrote: On Tuesday 05 February 2008 12:02, Tiziano De Togni wrote: Michael Van Canneyt ha scritto: The advantage is mainly that you can have objects on the stack. sorry, but don't understand exactly what this means exactly. The main difference is here: -- 8 -- procedure Uses_Objects; var My_Object : tMyObject; My_Class : tMyClass; begin My_Object.Init; My_Class := tMyClass.Create; end {Uses_Objects}; -- 8 -- The memory allocation for the class can fail due to resource exhaustion and also is infinitely slower than the allocation for the object, which is there as soon as the procedure has been entered. On assembly level, it is only a different constant that the stack pointer is moved to make space for the local variables. Referencing an instance being on the stack may also be a bit faster than referencing an instance being on the heap, because there's one level of dereference less, and it may be even more cache-friendly, because the stack is more likely to be in the cache already than a (newly) allocated memory block. Meaning: Memory space and execution speed is more or less known beforehand and potential memory fragmentation problems are avoided. Oh, and one thing more: No access violations when referencing an invalid (not yet initialized) instance. ;) Another difference, the memory of a class is zeroed on creation. This means that all membervars have the value of 0/nil, where for an object only automated member types are initialized. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
Daniël Mantione wrote: Op Tue, 5 Feb 2008, schreef Marc Weustink: Daniël Mantione wrote: Op Tue, 5 Feb 2008, schreef Luiz Americo Pereira Camara: can i safely use the below object instead of the record and pass directly to the c function? TMyObj = object x: Integer; y: Integer; Method1; Method2; end; PMyObj = ^TMyObj; Yes, objects (by specification) are defined to have the same binary layout as records. Moreover, whats the difference between objects and records with methods (the new Delphi feature)? Objects can have virtual methods, constructors, destructors. The new Delphi feature cannot. however with virtuals or constructors/destructors, the memory layout is not 100% the same as a record. A constructor doesn't add a vmtlink. A virtual method does, and a destructor too because they are virtual. It is never a problem in practise, because you can declare the virtual method in a descendent, i.e.: type Tbinary_compatible_obj=object a,b,c,d,e,f:byte; constructor init; end; Tbinary_compatible_obj_with_vmt=object(Tbinary_compatible_record) constructur init; procedure virtualmethod;virtual; desctructor done;virtual; end; In the above example, you can perfectly pass a Tbinary_compatible_obj_with_vmt instance to any C library expecting a Tbinary_compatible_obj, because the vmtlink is located after the fields and therefore does not interfere with the binary structure. it might be a compiler bug, but when I tried to zeromem a object having a constructor it resulted in an IE. Without a constructor not. That way I came to a conlusion that an object+constructor is not 100% the same as a simple record. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Converting StrLCopy to widestrings
Felipe Monteiro de Carvalho wrote: On Nov 17, 2007 1:25 PM, Marc Weustink [EMAIL PROTECTED] wrote: First question, why is the copying needed ? Why isn'tlpStrFile := PWChar(FileNameWide); simply enough ? IMO, you're copying way to much. That variable is only valid on the scope of the function, and we need something more permanent. I need to review the code in that area, imo it is not needed. anyway when is the allocateed memory freed ? Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Converting StrLCopy to widestrings
Felipe Monteiro de Carvalho wrote: Hello, In a LCL code we have: var FileNameBuffer: PChar; FileNameWide: WideString; FileNameWideBuffer: PWideChar; FilterBuffer: WideString; begin {$ifdef WindowsUnicodeSupport} if UnicodeEnabledOS then FileNameWideBuffer := AllocMem(FileNameBufferLen * 2 + 2) else FileNameBuffer := AllocMem(FileNameBufferLen + 1); {$else} FileNameBuffer := AllocMem(FileNameBufferLen + 1); {$endif} . {$ifdef WindowsUnicodeSupport} if UnicodeEnabledOS then begin FileNameWide := UTF8Decode(FileName); { StrLCopy is a PChar function, so it won't create a proper 2-byte sized ending and we ensure that it's there by cleaning the string } FillChar(FileNameWideBuffer^, FileNameBufferLen * 2 + 2, #0); StrLCopy(PChar(FileNameWideBuffer), PChar(PWideChar(FileNameWide)), FileNameBufferLen * 2); end else StrLCopy(FileNameBuffer, PChar(UTF8ToAnsi(FileName)), FileNameBufferLen); {$else} StrLCopy(FileNameBuffer, PChar(FileName), FileNameBufferLen); {$endif} ... {$ifdef WindowsUnicodeSupport} if UnicodeEnabledOS then begin lpStrFile := PChar(FileNameWideBuffer); . First question, why is the copying needed ? Why isn'tlpStrFile := PWChar(FileNameWide); simply enough ? IMO, you're copying way to much. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Help making code unicode capable
Felipe Monteiro de Carvalho wrote: Hello, I have a small piece of code on LCL which I have found hard to convert to unicode: lpStrFilter := StrAlloc(Length(Filter)+1); StrPCopy(lpStrFilter, Filter); There is a big chance that this is an inheritence of the pre 1.0 fpc times. At that time Casting a string to a PChar didn't work reliable, so all in all cases where you now would use PChar(S) these constructs where used. I think in this case you now simply can use a sting (or widestring) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Help making code unicode capable
Mattias Gaertner wrote: On Sat, 10 Nov 2007 15:44:54 +0100 Felipe Monteiro de Carvalho [EMAIL PROTECTED] wrote: Thanks, I arrived at this: var FilterBuffer: WideString; ... FilterBuffer := Utf8Decode(Filter); lpStrFilter := GetMem(Length(FilterBuffer) * 2 + 2); Move(FilterBuffer, lpStrFilter, Length(FilterBuffer) * 2 + 2); But now it crashes when loading the dialog =/ any ideas? Move(FilterBuffer[0], lpStrFilter^, Length(FilterBuffer) * 2 + 2); See my other mail, I think that lpStrFilter := PWChar(FilterBuffer) should work here. No need for a temp buffer. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPC now 3rd in shootout
S. Fisher wrote: --- Marco van de Voort [EMAIL PROTECTED] wrote: http://shootout.alioth.debian.org/gp4/benchmark.php?test=alllang=all The reason is that D's mean degraded from 1.40 to 1.43. I wonder how that could happen. They change often. Clean is also quite variable. I assume the differences are simply in the magnitude of the uncertainty of the measuring. I submitted this regex-dna program on 2007-10-31. It's still in limbo: neither accepted nor rejected. { The Computer Language Benchmarks Game http://shootout.alioth.debian.org contributed by Steve Fisher compile with fpc -O3 regex-dna.pp } uses regexpr, strutils; function replace_matches( const target: pchar; const repl: pchar; const str: ansistring; var dest: ansistring ): longint; var engine : tRegexprEngine; substr : ansistring; count, index, size : longint; begin if not GenerateRegExprEngine( target, [], engine) then begin writeln( 'Failed to generate regex. engine for ',target,'.' ); halt(1) end; count := 0; dest := ''; substr := str; while length(substr) 0 do begin if RegExprPos(engine, pchar(substr), index, size ) then begin count += 1; dest += ansiLeftStr( substr, index) + repl; substr := ansiRightStr(substr,length(substr)-index-size); end else break end; DestroyRegExprEngine( engine ); dest += substr; exit(count) end; function count_matches( target: pchar; const str: ansistring ): longint; var engine : tRegexprEngine; substr : ansistring; count, index, size : longint; begin if not GenerateRegExprEngine( target, [ref_caseinsensitive], engine) then begin writeln( 'Failed to generate regex. engine for ',target,'.' ); halt(1) end; For this benchmark you don't need extra unneeded code for checking conditions. If the test fails it fails, so don't worry on errors Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] more questions on storage
Mattias Gaertner wrote: On Thu, 27 Sep 2007 12:38:13 +0200 (CEST) [EMAIL PROTECTED] (Marco van de Voort) wrote: [EMAIL PROTECTED] (Marco van de Voort) wrote: A cast is really a cast. IOW the cast pchar(ansistring) is mostly a no-op. Traditional C code then usually treats the #0 as end of string. PChar(AnsiString) was a no-op typecast in the past and is nowadays a function. It checks whether the AnsiString is nil and if yes returns a pointer to a string containing one character: #0. That means: Pointer(AnsiString) Pointer(PChar(AnsiString)) To get a no-op typecase you can use: MyPChar:=PChar(Pointer(AnsiString)); Is this delphi compat, and if yes, what is this exactly for? I don't know. The change broke some lazarus code and now it is polluted by the ugly double type casts, just to get some no-op type casts. Because this fact is not widely known or often forgotten, many use the PChar() as simple type cast. That's why the lcl interfaces already got into troubles several times, so everytime we get strange errors I first search for these typecasts. Maybe we should mention this fact at a more prominent place in the wiki and docs. Maybe also add another type to get the OldTypecase behaviour. I allways thought that casting through Pointer() did return the real allocated data (thus including reference and length) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Usage of TInterfacedObject. Automatic release?
Luiz Americo Pereira Camara wrote: Cesar Romero wrote: Luiz Americo, Anyway, calling manually _Release avoid the leak and i will stay with it for now (I hope did not break anything). It can work for that case, but I think that is not a good ideia. If you are using a TInterfacedObject descendant, it will call the _Release when out of context, so in that especific case seems to never go out of context, and then you _realease call works, but in other place it can go out of context before, and the you will have others AV. - As Joao suggest, the best way is create a weak reference, where when 2 objects need to reference each other one should use Pointer to hold one reference - Avoid circular reference The problem here is that i'm using a third party design. And the code complexity allied with my inexperience with interfaces/COM makes the chance of breaking things big. Anyway i did not find, with my limitations, any circular references between interfaces. Exists a circular reference but is between an Interface (IVTDragManager) and a TVirtualTreeView(TCustomControl) already used as a weak reference (TObject). The design is more or less the following: TBaseVirtualTree holds a reference to a IVTDragManager. TVTDragManager (IVTDragManager) holds a reference to TBaseVirtualTree stored in a TObject field TVTDragManager also holds reference for IDataObject (TVTDataObject) and IDropTargetHelper (returned by a win32 call) TVTDataObject holds a reference to TBaseVirtualTree as a TObject There are two circular references: TVTDragManager - TBaseVirtualTree TBaseVirtualTree - TVTDragManager TVTDataObject TBaseVirtualTree Circular references of object is not the problem, you should look at circular references of interfaces. However, I don't expect that this is the case for the virtualtree. THat you need a _release for fpc and not for delphi sounds like a bug in fpc. (only where) Normally you never ever have to call _release yourself (unless you called _addref yourself) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] gcc beats fpc again
Daniël Mantione wrote: Op Wed, 23 May 2007, schreef Bisma Jayadi: No C programs have been submitted recently. It is probably the new broken scoring system. Is Shootout using new scoring system? How did you know that? See the long thread on the forum. It penalizes Pascal because we have a bad score for Chameneos; many languages, evade this now by not implementing Chameneos. Ironically, this is because most implementations use a flawed Chameneos implementation. Perhaps we should submit a flawed implementation too. Maybe I can find my initial implementation again. IIRC it was about 10 times faster ;-) (or was it 5) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Release of fpc-2.1.4 aka 2.2.0-beta
bartek wrote: Hi, I tried to compile my current project with the new compiler (2.1.4). This resulted in the following error: -8- /home/bartek/Dev/units/vmath.pp(435,29) Error: Can't take the address of constant expressions -8- -8- destructor TLazyVariableManager.Destroy; var i: integer; begin for i:=0 to LazyVariableList.count -1 do TLazyVector4(LazyVariableList.items[i]).Free; freeandnil(LazyVariableList); // -- 435 is here end; -8- The error is IMO somewhat cryptic, but you cannot pass a property as var parameter anymore. This to be inline with properties implemented by a Setter. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Freepascal and Lazarus at the Dutch HCC dagen
Hi, Just to let you know that Freepascal and Lazarus are present at the Dutch HCC dagen the coming 3 days at the PascalGG stand. Marco, Joost and I will be there. CU, Marc Location (Dutch) http://www.delphigg.nl/Hcc/HalAlleStands.html ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problem with multiple inheritance
Felipe Monteiro de Carvalho wrote: Hello, I was trying to split the o-o wrappers around Qt procedural wrappers in 2 parts. One that depends on Lazarus and another that can be used with only Free Pascal. So I have some classes like this: TQtWidget = class(TObject) TQtFrame = class(TQtWidget) Both classes contain mixed code for accessing Qt functions and procedures specific for Lazarus, like Event loops, methods that receive lazarus classes, methods to receive event signals, etc. So I would now have, after splitting: For pure Qt: TQtWidget = class(TObject) TQtFrame = class(TQtWidget) And for laz parts: TLazQtWidget = class(TObject) TLazQtFrame = class(TLazQtWidget, TQtFrame) The problem is that on TLazQtFrame I would like to inherit all functions from a normal TQtFrame, but I would also like to inherit all functions from TLazQtWidget. How can I work around this? I mean, how can I redesign my idea to make it work with FP? Note that Qt requires that all methods to receive events, and signals be from objects (I cannot use a procedure to receive events). Use the TQt class tree as a private for the TQtWS class tree. The Qt tree doesn't have to match 1:1 to the WS tree. (exactly this problem made me inplement the virtusl classes :) Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Eye Candy Contest
Michael Van Canneyt wrote: On Wed, 1 Nov 2006, Marc PERTRON wrote: Hi, I'd like to show to some people that FreePascal can do good graphical and efficient things :o) So I organise an eye candy contest, with some simple rules, and I'll give three rewards ($150, $100 and $50) for the three best programs. Independent of this, you may want to show your 'people': http://www.freepascal.org/gallery.html Ehm how to get there from the main site (and shouldn't lazarus be there as well) ? Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Problem with string conversion
Felipe Monteiro de Carvalho wrote: On 10/20/06, Vincent Snijders [EMAIL PROTECTED] wrote: This should be WideText := GetMem(Size*2); because you get the number of characters, and the number of bytes 2* number of characters. Thanks, it works, but I still have doubts. 1) On linux I will need that cwstring unit, right? This was a utf-8 test to be used on fpGUI, and possibly LCL. So can´t we just add cwstring on another unit instead of the first of the program? 2) Does this work in case my string contains characters bigger then # ? I mean, it seams that we suppose that each character will have 2 bytes, but this may not be true. IMO, Utf8ToUnicode should return the number of bytes the unicode string requires and not the number of characters. Since even for unicode, one char may take more than one word. I don't know what it returns atm. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 2.1.1 new protected
Martin Schreiber wrote: On Friday 11 August 2006 20.35, Marc Weustink wrote: What's the alternative? To have most of internal procedures public with a comment for internal use only, I really don't like it, or to have all code in a single file, I don't like it too. What about friend units'? Or something like as it is solved in delphi with helper classes (p215). (Maybe we can also implement the strict version (p168)) http://info.borland.com/techpubs/delphi/Delphi2006/Reference.pdf It seems that FPC 2.1.1 implements the behaviour of Delphi 2006 'strict protected' by default. I don't think so, the delphi 2006 strict syntax is more strict. The example you gave below is (afaik) still possible in FPC, which wouldn't if it was strict. Marc In MSEgui I have the problem that there is too much low level stuff to fit in one unit and the dependences are too complex to be mapped into a simple class hierarchy. Up to time I did as follows to access low level elements of classes in other units: implementation type TLowLevelClassInOtherUnit1 = class(TLowLevelClassInOtherUnit); procedure TLowLevelClassInThisUnit.DoSomething; begin TLowLevelClassInOtherUnit1 (InstanceOfTLowLevelClassInOtherUnit).DoSomethingProtected; end; It is ugly, produces warnings and is possibly forbidden in FPC 2.1.1 (I don't know). A more elegant solution would be to have something like 'friend units' where protected class members are visible: unit secondlowlevelunit; interface uses firstlowlevelunit,highlevelunit; friends//use appropriate keyword and notation firstlowlevelunit; - In secondlowlevelunit all protected class members of firstlowlevelunit are visible, protected class members of highlevelunit are visible in descendant classes. Martin ___ 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] 2.1.1 new protected
Martin Schreiber wrote: On Friday 11 August 2006 13.58, Mattias Gaertner wrote: On Fri, 11 Aug 2006 13:42:49 +0200 Florian Klaempfl [EMAIL PROTECTED] wrote: Mattias Gaertner wrote: Recently the behaviour of the 'protected' keyword has changed in fpc 2.1.1. Now I wonder how can I fix the code, that depends on this. Redesign :) Of FPC? Naaah, too much work. ;) Of my code: Yes, but how? Looking at the Delphi sources, I see that Borland has made many such methods public, which resulted in Code using the VCL the wrong way and creating VCL version dependent conflicts. I want to avoid this, and the old protected allowed that. But now I can't find any good alternative. Agreed, same for MSEide+MSEgui. In a big GUI system it is not possible to handle all low level stuff in a simple class hierarchy, there must be a way to access protected methods of other instances and classes in other units. What's the alternative? To have most of internal procedures public with a comment for internal use only, I really don't like it, or to have all code in a single file, I don't like it too. What about friend units'? Or something like as it is solved in delphi with helper classes (p215). (Maybe we can also implement the strict version (p168)) http://info.borland.com/techpubs/delphi/Delphi2006/Reference.pdf Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Common OpenMP syntax?
Steve Williams wrote: Florian Klaempfl wrote: I'am currently thinking about implementing OpenMP support in FPC. However, there is currently (to my knowledge) no pascal syntax defined for OpenMp support. Do you think we can find a common syntax to simplify things for users? I've some ideas how it be done, but I want to hear other ideas first so they are maybe better if they aren't influenced by my ideas :) I started also a wiki page about it http://www.freepascal.org/wiki/index.php/OpenMP_support where ideas can be written down and shared. I would suggest something along the lines of the C/C++ implementation, but using the Pascal form of compiler directives. Using some of the documented examples in the v2.5 spec: Example A.1.1: procedure a1(n: Integer; a: PSingleArray; b: PSingleArray); var i: Integer; begin {$omp parallel for} for i := 1 to n - 1 do b^[i] := (a^[i] + a^[i - 1]) / 2.0; end; Brrr using local defines look not native to the language. Why not something like as (refered in another thread) pascal-fc which uses cobegin..coend or known blocks like asm..end; try..end; for instance: omp..end; parralel..end; so: procedure a1(n: Integer; a: PSingleArray; b: PSingleArray); var i: Integer; begin for i := 1 to n - 1 do parallel b^[i] := (a^[i] + a^[i - 1]) / 2.0; end; end; Example A.5.1: uses omp; begin omp_set_dynamic(1); {$omp parallel num_threads(10)} begin (* Do work here *) end; end; uses omp; begin omp_set_dynamic(1); // {$omp parallel num_threads(10)} // why not: omp_set_num_threads(10); parallel (* Do work here *) end; end; Example A.13.1: interface function dequeue(var a: Single): Integer; procedure work(i: Integer; var a: Single); implementation procedure a13(var x: Single; var y: Single); var ix_next, iy_next: Integer; begin {$omp parallel shared(x, y) private(ix_next, iy_next)} begin {$omp critical (xaxis)} ix_next := dequeue(x); work(ix_next, x); {$omp critical (yaxis)} iy_next := dequeue(y); work(iy_next, y); end; end; procedure a13(var ax: Single; var ay: Single); begin parallel shared x: Single; absolute ax; y: Single; absolute ay; private ix_next, iy_next: Integer; begin // where does xaxis come from ? // {$omp critical (xaxis)} ix_next := dequeue(x); work(ix_next, x); // where does yaxis come from ? // {$omp critical (yaxis)} iy_next := dequeue(y); work(iy_next, y); end; end; or: procedure a13(var ax: Single; shared var y: Single); shared var x: Single; absolute ax; // y: Single; absolute ay; private var ix_next, iy_next: Integer; begin parallel // where does xaxis come from ? // {$omp critical (xaxis)} ix_next := dequeue(x); work(ix_next, x); // where does yaxis come from ? // {$omp critical (yaxis)} iy_next := dequeue(y); work(iy_next, y); end; end; Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Common OpenMP syntax?
Steve Williams wrote: Marc Weustink wrote: Steve Williams wrote: I would suggest something along the lines of the C/C++ implementation, but using the Pascal form of compiler directives. Using some of the documented examples in the v2.5 spec: Example A.1.1: procedure a1(n: Integer; a: PSingleArray; b: PSingleArray); var i: Integer; begin {$omp parallel for} for i := 1 to n - 1 do b^[i] := (a^[i] + a^[i - 1]) / 2.0; end; Brrr using local defines look not native to the language. Why not something like as (refered in another thread) pascal-fc which uses cobegin..coend or known blocks like asm..end; try..end; for instance: omp..end; parralel..end; One of the pretexts behind OpenMP is that the code will still compile if OpenMP is not available or disabled on a particular compiler. Mwah... in that case you can still use the same keywords, only it won't be much parallel, since it's executed in one thread. And beeing executed in one or more threads should not matter in parallel blocks. Marc That's the reason behind using compiler directives instead of new keywords. Using compiler directives similar to the C/C++ directives also means eehh... to repeat what someone else already mentioned in this thread, if I want to use C, I don't use pascal. Marc. that the wealth of information already out there is instantly applicable to the Pascal version. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Common OpenMP syntax?
Florian Klaempfl [EMAIL PROTECTED] wrote: I'am currently thinking about implementing OpenMP support in FPC. Is this similar as polyphinic C# ? (you gave me a link a while ago) What I'm puzzeled with, usually an API specifies the interface to an external library, where here it seems a spec how a language should behave when implementing Multi Processing (and in this case for C++ and Fortran). Is the idea to implement a similar, based on the ideas of openMP, version for FPC? Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal