[fpc-pascal] Open vs dynamic arrays

2012-04-22 Thread Mark Morgan Lloyd
I know this is an area of some confusion, and the more explanations I read the more I'm confused. I've got a procedure like this procedure ClrDebug(const panels: array of const); var i: integer; begin for i := 0 to Length(panels) - 1 do ClrDebug(panels[i]) end { ClrDebug

Re: [fpc-pascal] Open vs dynamic arrays

2012-04-22 Thread cobines
ClrDebug(panels[i]) calls itself again and not procedure ClrDebug(panel: integer)... So stack overflow happens. If you need it only for integers then declare it as: procedure ClrDebug(const panels: array of integer) -- cobines ___ fpc-pascal maillist

Re: [fpc-pascal] Open vs dynamic arrays

2012-04-22 Thread Mark Morgan Lloyd
cobines wrote: ClrDebug(panels[i]) calls itself again and not procedure ClrDebug(panel: integer)... So stack overflow happens. If you need it only for integers then declare it as: procedure ClrDebug(const panels: array of integer) Thanks. Making sure it couldn't recurse fixes half the probl

Re: [fpc-pascal] Open vs dynamic arrays

2012-04-22 Thread cobines
2012/4/22 Mark Morgan Lloyd : > but I'm not sure why that works when it > didn't earlier (i.e. before I'd started using array of const). You said you used DbgArray= array of integer then I assume this declaration? procedure ClrDebug(const panels: DbgArray); If so the parameter is a dynamic arra

Re: [fpc-pascal] Open vs dynamic arrays

2012-04-22 Thread Mark Morgan Lloyd
cobines wrote: 2012/4/22 Mark Morgan Lloyd : but I'm not sure why that works when it didn't earlier (i.e. before I'd started using array of const). You said you used DbgArray= array of integer then I assume this declaration? procedure ClrDebug(const panels: DbgArray); If so the parameter is

Re: [fpc-pascal] Open vs dynamic arrays

2012-04-22 Thread Michael Van Canneyt
On Sun, 22 Apr 2012, Mark Morgan Lloyd wrote: cobines wrote: 2012/4/22 Mark Morgan Lloyd : but I'm not sure why that works when it didn't earlier (i.e. before I'd started using array of const). You said you used DbgArray= array of integer then I assume this declaration? procedure ClrDebu

Re: [fpc-pascal] Open vs dynamic arrays

2012-04-22 Thread Mark Morgan Lloyd
Michael Van Canneyt wrote: On Sun, 22 Apr 2012, Mark Morgan Lloyd wrote: cobines wrote: 2012/4/22 Mark Morgan Lloyd : but I'm not sure why that works when it didn't earlier (i.e. before I'd started using array of const). You said you used DbgArray= array of integer then I assume this decl

Re: [fpc-pascal] Open vs dynamic arrays

2012-04-22 Thread Jonas Maebe
On 22 Apr 2012, at 12:54, Mark Morgan Lloyd wrote: > you quite simply can't do that when there isn't an explicit index range since > your attempt to define an open array is interpreted as a dynamic array. Yes. The reason is that you can't declare variables whose type is "open array". In fact,

Re: [fpc-pascal] header translation question: I need an int sized boolean

2012-04-22 Thread David W Noon
On Sun, 22 Apr 2012 01:54:17 +0200, Bernd wrote about [fpc-pascal] header translation question: I need an int sized boolean: >I have this from the GLIB heads: > >typedef intgint; >typedef gint gboolean; > >Now I need a few packed records with such gboolean types in them. On >my i386 I am now

Re: [fpc-pascal] header translation question: I need an int sized boolean

2012-04-22 Thread Bernd
2012/4/22 David W Noon : >  Without any "long" prefix > an integer remains 32-bit. > [...] > Leave it as you currently have it. Thanks, this sounds good. For the record: I was trying to port this: http://developer.pidgin.im/wiki/CHowTo/BasicPluginHowto to FPC and now I have posted the results o

Re: [fpc-pascal] header translation question: I need an int sized boolean

2012-04-22 Thread Mattias Gaertner
On Sun, 22 Apr 2012 01:54:17 +0200 Bernd wrote: > Hi, > > I have this from the GLIB heads: > > typedef intgint; > typedef gint gboolean; Why not use gboolean from the glib unit? Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.o

Re: [fpc-pascal] header translation question: I need an int sized boolean

2012-04-22 Thread Bernd
Am 22. April 2012 16:46 schrieb Mattias Gaertner : > Why not use gboolean from the glib unit? I didn't know it exists, so I didn't even try to search for it Thanks for the info :-) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.

Re: [fpc-pascal] header translation question: I need an int sized boolean

2012-04-22 Thread Marco van de Voort
In our previous episode, Bernd said: > I have this from the GLIB heads: > > typedef intgint; > typedef gint gboolean; > > Now I need a few packed records with such gboolean types in them. On > my i386 I am now just using That's afaik a wrong translation. longbool are true <>0, while gboole

Re: [fpc-pascal] header translation question: I need an int sized boolean

2012-04-22 Thread Bernd
Am 22. April 2012 17:39 schrieb Marco van de Voort : > FPC 2.6.0+ introduced boolean8/16/32/64 types for this. I just saw it in gtypes.inc and wondered what this is, this is the first time I have seen these new boolean types. Also Lazarus does not yet know about them in the code completion.

Re: [fpc-pascal] header translation question: I need an int sized boolean

2012-04-22 Thread Bernd
Am 22. April 2012 17:39 schrieb Marco van de Voort : > gboolean, > like Pascal booleans, are only true =1. Just out of curiosity, how can they enforce this for the C compiler with only some definitions in a header file? Isn't it just an alias for int? what if i just write gboolean something; som

Re: [fpc-pascal] header translation question: I need an int sized boolean

2012-04-22 Thread Marco van de Voort
In our previous episode, Bernd said: > Am 22. April 2012 17:39 schrieb Marco van de Voort : > > gboolean, > > like Pascal booleans, are only true =1. > > Just out of curiosity, how can they enforce this for the C compiler > with only some definitions in a header file? I don't know, I don't use GT