Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-09

PACKENUM and MINENUMSIZE

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Lukas Gradl

Hi!

Could anyone help me determining the defaults for MINENUMSIZE / PACKENUM?

As far as I could find in the docs it depends on $MODE: for $MODE OBJPAS it's 4 but I could'nt find the default for $MODE DELPHI.

Is there a difference between the CPU-Flavor used (i386 contra X64)?

AFAIK this seems to be the problem with UIB in X64 posted earlier but I'm not shure so far....

regards
Lukas

-------------------------- software security networks Lukas Gradl <fpc#ssn.at> Eduard-Bodem-Gasse 9 A - 6020 Innsbruck Tel: +43-512-214040-0 Fax: +43-512-214040-21 --------------------------
Michael Van Canneyt
to Lukas Gradl
Lukas Gradl wrote 6 lines
Hi! Could anyone help me determining the defaults for MINENUMSIZE / PACKENUM? As far as I could find in the docs it depends on $MODE: for $MODE OBJPAS it's 4 but I could'nt find the default for $MODE DELPHI.

Where did you read that this depends on $MODE ?

It just says that the default (contrary to Delphi) is 4.

Is there a difference between the CPU-Flavor used (i386 contra X64)?

Normally not, as far as I know it depends on the number of elements in the enumerated ?

Michael.

Marco van de Voort
to Michael Van Canneyt

In our previous episode, Michael Van Canneyt said:

Show quoted text 5 lines
> As far as I could find in the docs it depends on $MODE: for $MODE OBJPAS it's > 4 but I could'nt find the default for $MODE DELPHI. Where did you read that this depends on $MODE ? It just says that the default (contrary to Delphi) is 4.

Then the doc is wrong, since sizeof (enum with one element) is 1 in Delphi mode.

Michael Van Canneyt
to Marco van de Voort
Marco van de Voort wrote 9 lines
In our previous episode, Michael Van Canneyt said: > > As far as I could find in the docs it depends on $MODE: for $MODE OBJPAS it's > > 4 but I could'nt find the default for $MODE DELPHI. > > Where did you read that this depends on $MODE ? > It just says that the default (contrary to Delphi) is 4. Then the doc is wrong, since sizeof (enum with one element) is 1 in Delphi mode.

No problem, if someone would tell me the exact behaviour, I will change it.

Michael.

Lukas Gradl
to Michael Van Canneyt

As far as i can understand the fpc sources it's in compiler/scanner.pas, line 359ff:

            { Default enum packing for delphi/tp7 }
            if (m_tp7 in current_settings.modeswitches) or
               (m_delphi in current_settings.modeswitches) then
              current_settings.packenum:=1
            else if (m_mac in current_settings.modeswitches) then
              { compatible with Metrowerks Pascal }
              current_settings.packenum:=2
            else
              current_settings.packenum:=4;

So it would be 1 fpr Delphi and TP7 mode, 2 for mac (don't know that) and 4 for all others.

Did a little test program on that. With {$mode objfpc} result is 4, with

  {$mode delphi} result is 1. (And the most important for me: Its the

solution to my problem with UIB - will post the reason as an answer to that posting!)

program Project1;
{$mode objfpc}
{$H+}
Uses SysUtils;

type
TEnumTestType = (
etOne,
etTwo,
etThree,
etFour,
etFive,
etSix,
etSeven,
etEight,
etNine,
etTen,
etEleven,
etTwelve,
etThirteen,
etForteen

   );
var
   ET: TEnumTestType;
begin
   writeln(IntToStr(SizeOf(ET)));
end.

Regards
Lukas

Show quoted text 18 lines
On Thu, 11 Sep 2008, Marco van de Voort wrote: > In our previous episode, Michael Van Canneyt said: >>> As far as I could find in the docs it depends on $MODE: for $MODE OBJPAS it's >>> 4 but I could'nt find the default for $MODE DELPHI. >> Where did you read that this depends on $MODE ? >> It just says that the default (contrary to Delphi) is 4. > Then the doc is wrong, since sizeof (enum with one element) is 1 in Delphi > mode. No problem, if someone would tell me the exact behaviour, I will change it. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
-------------------------- software security networks Lukas Gradl <fpc#ssn.at> Eduard-Bodem-Gasse 9 A - 6020 Innsbruck Tel: +43-512-214040-0 Fax: +43-512-214040-21 --------------------------
Lukas Gradl
to Lukas Gradl

Forgot to add: No difference between i386 and x64.

regards
Lukas

Show quoted text 80 lines
As far as i can understand the fpc sources it's in compiler/scanner.pas, line 359ff: { Default enum packing for delphi/tp7 } if (m_tp7 in current_settings.modeswitches) or (m_delphi in current_settings.modeswitches) then current_settings.packenum:=1 else if (m_mac in current_settings.modeswitches) then { compatible with Metrowerks Pascal } current_settings.packenum:=2 else current_settings.packenum:=4; So it would be 1 fpr Delphi and TP7 mode, 2 for mac (don't know that) and 4 for all others. Did a little test program on that. With {$mode objfpc} result is 4, with {$mode delphi} result is 1. (And the most important for me: Its the solution to my problem with UIB - will post the reason as an answer to that posting!) program Project1; {$mode objfpc} {$H+} Uses SysUtils; type TEnumTestType = ( etOne, etTwo, etThree, etFour, etFive, etSix, etSeven, etEight, etNine, etTen, etEleven, etTwelve, etThirteen, etForteen ); var ET: TEnumTestType; begin writeln(IntToStr(SizeOf(ET))); end. Regards Lukas Michael Van Canneyt schrieb: > > On Thu, 11 Sep 2008, Marco van de Voort wrote: > >> In our previous episode, Michael Van Canneyt said: >>>> As far as I could find in the docs it depends on $MODE: for $MODE >>>> OBJPAS it's >>>> 4 but I could'nt find the default for $MODE DELPHI. >>> Where did you read that this depends on $MODE ? >>> It just says that the default (contrary to Delphi) is 4. >> Then the doc is wrong, since sizeof (enum with one element) is 1 in >> Delphi >> mode. > > No problem, if someone would tell me the exact behaviour, I will > change it. > > Michael. > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >
-------------------------- software security networks Lukas Gradl <fpc#ssn.at> Eduard-Bodem-Gasse 9 A - 6020 Innsbruck Tel: +43-512-214040-0 Fax: +43-512-214040-21 --------------------------
Michael Van Canneyt
to Lukas Gradl
Lukas Gradl wrote
Forgot to add: No difference between i386 and x64.

Thanks, I updated the programmer's guide so the default sizes are now documented.

Michael.