Sign in Join

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

Mailing lists / fpc-pascal / 2010-03

Error: Illegal qualifier in converting Delphi unit

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Frank Church

Hi guys,

I am trying to compile the TVersionInfo component by Anders Melander at http://melander.dk/articles/versioninfo/.

It defines the structure below

type
  TTranslationRec = packed record
    case Integer of
    0: (
      LanguageID: WORD;
      CharsetID: WORD);
    1: (
      TranslationID: DWORD);
  end;
  PTranslationRec = ^TTranslationRec;
  TTranslationTable = array[0..0] of TTranslationRec;
  PTranslationTable = ^TTranslationTable;

which causes the compiler error

VersionInfo.pas(141,37) Error: Illegal qualifier
function TVersionInfo.GetCharset(Index: integer): WORD;
begin
  Result := TranslationTable[Index].CharsetID;
end;

Is there a way to convert for Free Pascal compatibility?

Frank Church ======================= http://devblog.brahmancreations.com

Reply by email

Howard Page-Clark
to Frank Church
Frank Church wrote 31 lines
Hi guys, I am trying to compile the TVersionInfo component by Anders Melander at http://melander.dk/articles/versioninfo/. It defines the structure below type TTranslationRec = packed record case Integer of 0: ( LanguageID: WORD; CharsetID: WORD); 1: ( TranslationID: DWORD); end; PTranslationRec = ^TTranslationRec; TTranslationTable = array[0..0] of TTranslationRec; PTranslationTable = ^TTranslationTable; which causes the compiler error VersionInfo.pas(141,37) Error: Illegal qualifier function TVersionInfo.GetCharset(Index: integer): WORD; begin Result := TranslationTable[Index].CharsetID; end; Is there a way to convert for Free Pascal compatibility?

try:

  result := TranslationTable[Index]^.CharsetID

Howard

Reply by email

Frank Church
to Howard Page-Clark

Your suggestion worked - what is the secret?
Does the array[0..0 have some relevance here?]

Howard Page-Clark wrote 43 lines
On 14/3/10 6:11, Frank Church wrote: > > Hi guys, > > I am trying to compile the TVersionInfo component by Anders Melander > at http://melander.dk/articles/versioninfo/. > > It defines the structure below > > type >   TTranslationRec = packed record >     case Integer of >     0: ( >       LanguageID: WORD; >       CharsetID: WORD); >     1: ( >       TranslationID: DWORD); >   end; >   PTranslationRec = ^TTranslationRec; >   TTranslationTable = array[0..0] of TTranslationRec; >   PTranslationTable = ^TTranslationTable; > > > which causes the compiler error > > VersionInfo.pas(141,37) Error: Illegal qualifier > > function TVersionInfo.GetCharset(Index: integer): WORD; > begin >   Result := TranslationTable[Index].CharsetID; > end; > > Is there a way to convert for Free Pascal compatibility?  try:  result := TranslationTable[Index]^.CharsetID Howard _______________________________________________ fpc-pascal maillist  -   http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Frank Church ======================= http://devblog.brahmancreations.com

Reply by email

Howard Page-Clark
to Frank Church
Frank Church wrote 43 lines
Your suggestion worked - what is the secret? Does the array[0..0 have some relevance here?] On 14 March 2010 23:01, Howard Page-Clark wrote: > On 14/3/10 6:11, Frank Church wrote: >> >> Hi guys, >> >> I am trying to compile the TVersionInfo component by Anders Melander >> at http://melander.dk/articles/versioninfo/. >> >> It defines the structure below >> >> type >> TTranslationRec = packed record >> case Integer of >> 0: ( >> LanguageID: WORD; >> CharsetID: WORD); >> 1: ( >> TranslationID: DWORD); >> end; >> PTranslationRec = ^TTranslationRec; >> TTranslationTable = array[0..0] of TTranslationRec; >> PTranslationTable = ^TTranslationTable; >> >> >> which causes the compiler error >> >> VersionInfo.pas(141,37) Error: Illegal qualifier >> >> function TVersionInfo.GetCharset(Index: integer): WORD; >> begin >> Result := TranslationTable[Index].CharsetID; >> end; >> >> Is there a way to convert for Free Pascal compatibility? > > try: > > result := TranslationTable[Index]^.CharsetID > > Howard

No secret - just that fpc requires stricter syntax than Delphi, even in {$mode Delphi}. The property TranslationTable is an array property declared as a pointer (PTranslationTable), so has to be dereferenced before its members can be accessed. It would have helped if the code's author had named the property PTranslationTable to highlight that fact, because the name hides its pointer character.

H

Reply by email

Marco van de Voort
to Howard Page-Clark

In our previous episode, Howard Page-Clark said:

Show quoted text 10 lines
>> result := TranslationTable[Index]^.CharsetID >> >> Howard No secret - just that fpc requires stricter syntax than Delphi, even in {$mode Delphi}. The property TranslationTable is an array property declared as a pointer (PTranslationTable), so has to be dereferenced before its members can be accessed. It would have helped if the code's author had named the property PTranslationTable to highlight that fact, because the name hides its pointer character.

Is there a bugreport about this? If not, pleasae do. $mode delphi not accepting this is not ok.

Reply by email