Illegal qualifier ошибка паскаль

You’re trying to access it as an array index, but it needs to be a function call:

MyChar.clas := classes(i);  { note () instead of [] }

You should probably add some range checking, too. What happens if someone puts 20 in the text file? Your array only has items at indexes 1 through 7, so you’ll get a runtime error when you call classes(20) with the out of range value.

(You could probably use a constant array for allclasses to lessen your code as well, but your instructor probably haven’t gotten that far yet.)

Given your comment about not having an instructor, here’s a suggestion about a better way to handle the function:

function classes(o:integer): String;
const
  allclasses: array[1..7] of string = ('class1', 
                                       'class2',
                                       'class3',
                                       'class4',
                                       'class5',
                                       'class6',
                                       'class7');
begin
  {
    Low() returns the lowest index of the array, and
    High() returns the highest. The if statement makes sure
    that o is between them. It is the range check I mentioned.
  }
  if (o >= Low(allclasses)) and (o <= High(allclasses)) then
    classes := allclasses[o]
  else
    classes := '';
end;

Topic: Illegal Qualifier  (Read 3893 times)

My compile terminates with 8 errors «Error: Illegal qualifier».

I’ve googled etc and so I have an idea of the kind of things I might be looking for. But the compiler doesn’t give me any location, not even a unit.

Is there anything I can do to get the compiler give me a location?


Logged


It means some name conflict in a path, i.e. some unit in your uses contain identifiers with the same name.

  1. unit Unit1;

  2. {$mode objfpc}{$H+}

  3. interface

  4. uses

  5.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs;

  6. type

  7. { TForm1 }

  8.   TForm1 = class(TForm)

  9. procedure FormCreate(Sender: TObject);

  10. private

  11. public

  12. end;

  13. var

  14.   Form1: TForm1;

  15.   Tag: TPoint;

  16. implementation

  17. {$R *.lfm}

  18. { TForm1 }

  19. procedure TForm1.FormCreate(Sender: TObject);

  20. begin

  21.   Tag.X:=4;

  22. end;

  23. end.

This code gives «Illegal Qualifier» error because Tag is also property of TForm. It is sibling error to «Duplicate identifier».


Logged


It’d be amazing for the cmopiler to give me a name or a location. I mean, I have some 150k lines of code to look through…


Logged


So it turns out that this is caused by a property declaration like this:

  1. property system : String read X write X;


Logged


system is reserved — for the hidden system unit — so can’t be used as a global property.


Logged

I actually get compliments for being rude… (well, Dutch, but that is the same)


So it turns out that this is caused by a property declaration like this:

  1. property system : String read X write X;

You didn’t get a line number along with the error message ?… if that is the case, it’s probably worth reporting as a bug.


Logged

FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 SP1 64bit.


Trying to verify my idea that the line number is not displayed because your compiler settings might not create debug information I tried this project:

  1. program Project1;

  2. uses

  3.   Classes;

  4. type

  5.   TSystemClass = class

  6. private

  7.     x: string;

  8. public

  9. property System: String read x write x;

  10. end;

  11. var

  12.   sc: TSystemClass;

  13. begin

  14.   sc := TSystemClass.Create;

  15. try

  16.     sc.System := ‘abc’;

  17. WriteLn(sc.System);

  18. finally

  19.     sc.Free;

  20. end;

  21. ReadLn;

  22. end.  

And it compiles and runs flawlessly… So, what exactly are you doing? Please present compilable code, no snippets.


Logged


Yes, I know, but what won’t work is a global property declaration. And FPC supports global properties.


Logged

I actually get compliments for being rude… (well, Dutch, but that is the same)


Well, this doesn’t compile:

  1. unit Unit1;

  2. interface

  3. type

  4.   TSystemClass = class

  5. private

  6. function getX: string; virtual; abstract;

  7. procedure setX(value: string); virtual; abstract;

  8. public

  9. property system: String read getX write setX;

  10. end;

  11. implementation

  12. end.

         

and

  1. program project1;

  2. uses

  3.   Classes, Unit1;

  4. begin

  5. end.  

 

It seems be both the property name and the virtual abstract accessors


Logged


Well, this doesn’t compile:

Don’t use System as the property name.


Logged


> Don’t use System as the property name.

Well, that might be — painful, especially since it’s supported in delphi. But what was really painful was the lack of information about what the problem was


Logged


> Don’t use System as the property name.

Well, that might be — painful, especially since it’s supported in delphi. But what was really painful was the lack of information about what the problem was

Have you tried prepending the name with a % or & , I forgot which one it is ?

That allows you to use reserved words.


Logged

The only true wisdom is knowing you know nothing


Well, this doesn’t compile:

  1. unit Unit1;

  2. interface

  3. type

  4.   TSystemClass = class

  5. private

  6. function getX: string; virtual; abstract;

  7. procedure setX(value: string); virtual; abstract;

  8. public

  9. property system: String read getX write setX;

  10. end;

  11. implementation

  12. end.

         
and

  1. program project1;

  2. uses

  3.   Classes, Unit1;

  4. begin

  5. end.  

 

It seems be both the property name and the virtual abstract accessors

Please report this as a bug. In this example the identifer

System

is part of the

TSystemClass

type, so it’s namespaced, thus this should work. And at least the compiler should properly show the error location.


Logged


  1. program Project1;

  2. //{$mode Delphi}

  3. {$mode objfpc}

  4. uses

  5.   Classes;

  6. type

  7.   TSystemClass = class

  8. private

  9.     x: string;

  10. function GetX: String; virtual; abstract;

  11. procedure SetX(value: String); virtual; abstract;

  12. public

  13. property System: String read GetX write SetX;

  14. end;

  15. begin

  16. end.  

The main question was: Why are there no messages about error locations? The above minimal code behaves exactly as reported in the first post, no matter whether mode Delphi or ObjFPC is selected: The error message is useless:

Compile Project, Target: D:Prog_Lazaruslazarus_test_projectsproject1.exe: Exit code 1, Errors: 2
Error: Illegal qualifier
Error: Illegal qualifier

So, I agree with PascalDragon and recommend reporting this as a bug to Mantis.


Logged


Misses «uses Classes».

Please post attachments within the forum as much as possible (paste from the clipboard and enclose in [

quote

] … [

/quote

] tags, or upload compilable, zipped projects under «Attachment and other options» below the edit box). Otherwise they will be removed sooner or later from external sites, and your post will become meaningless to others finding it at some time in the future.


Logged


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
 uses graph, LABA4, crt;
 const
  shag_setki=7;   {kolichestvo liniy v sisteme koordinat}
  otst=80;
  k=8.62e-5;
  n=1.45e10;
 var
  Nd,Na,a,T,b,sh:real;
  U,Tabs: array [0..25] of real;
  i,  r : integer;
  grDriver: integer;
  grMode: integer;
  ymax, xmax:integer;
  sh_y,sh_x,                   {shag setki po y & x}
  dx,dy:integer;               {delta x & delta y}
  T_max,T_min,U_max,U_min,     {maximalnie & minimalnie znacheniya n & E}
  dT,dU,                       {delta n & delta E}
  kx,ky:real;                  {koeficienti perevoda v pixeli}
  y,x:array [0..50] of integer;{massivi dlya postroeniya tochek}
  Tstr,Ustr: string;           {peremennie dlya preobrazovaniya znacheniy n & E v stroki}
begin
  clrscr;
  writeln('Enter the minimum temperature value in Kelvins ranging from 100 to 500');
  readln(a);
  writeln('Enter the maximum temperature value in Kelvins ranging from 100 to 500');
  readln(b);
  writeln('Enter step');
  readln(sh);
  writeln('Enter legitima impurity concentration in the range of from 5e13 to 1e18');
  readln(Na);
  Nd:=Na;
  T:=a;
  r:=trunc((b-a)/sh);
  for i:=0 to r do
    begin
      Tabs[i] := T;
      U[i] := UrovenFermi(T);
      T:=T+sh;
    end;
    Tablica(r,U,tabs);
    begin
    U[i]:=k*T*ln((Na*Nd)/(n*n));
    end;
    readln;
                  {nahozhdenie maximalnih & minimalnih znacheniy T & U}
   begin
    for i:=0 to r do
     begin
      if T[r] <= T[i] then T_max:= T[i] else T_min:=T[i];
      if T[0] < T[i] then T_min:= T[0] else T_max:= T[0];
      if U[0] <= U[i] then U_max:= U[i] else U_min:=U[i];
      if U[r] < U[i] then U_min:= U[0] else U_max:= U[0];
     end;
    dT:=T_max-T_min;
    dU:=U_max-U_min;
   end;
                          {vkluchenie graficheskogo rezhima}
  grDriver:=VGA;
  grMode:= VGAHi;
  InitGraph(grDriver,grMode,'');
                            {sozdanie koordinatnoy setki}
  ymax:= GetMaxY;
  xmax:= GetMaxX;
  sh_y:= round((ymax-otst-otst)/shag_setki);
  sh_x:= round((xmax-otst-otst)/shag_setki);
  SetLineStyle(DottedLn,2,NormWidth);
  SetColor(9);
    for i:=0 to shag_setki do
     begin
      line(otst,ymax-otst-sh_y*i,xmax-otst,ymax-otst-sh_y*i);
      line(otst+sh_x*i,ymax-otst,otst+sh_x*i,ymax-otst-sh_y*shag_setki);
     end;
                                {sozdanie ramki}
  SetLineStyle(SolidLn,0,NormWidth);
  SetColor(15);
   Rectangle(otst,ymax-otst-sh_y*shag_setki,otst+sh_x*shag_setki,ymax-otst);
                            {sozdanie podpisey na osyah}
  Setcolor(10);
   SetTextJustify(1,2);
    OutTextXY(otst+sh_x*shag_setki,ymax-otst+20, 'T, K');
   SetTextJustify(1,0);
    OutTextXY(otst,ymax-otst-sh_y*shag_setki-10, 'Fi, B');
                         {preobrazovanie znacheniy v stroki}
  SetColor(2);
  for  i:=0 to shag_setki do
     begin
      str(T[0]+dT/shag_setki*i:6,Tstr);
       SetTextJustify(1,1);
        OutTextXY(otst+sh_x*i,ymax-otst+15,Tstr);
      str(U[0]-dU/shag_setki*i:2:4,Ustr);
       SetTextJustify(2,1);
        OutTextXY(otst-2,ymax-otst-sh_y*shag_setki+sh_y*i,Ustr);
     end;
                           {sozdanie nazvaniya grafika}
  SetColor(3);
  SetTextJustify(1,2);
   OutTextXY(round(xmax/2),round(otst/2),'A graph of the built-in potential temperature');
                            {sozdanie tochek na grafike}
  dx:=sh_x*shag_setki;
  dy:=sh_y*shag_setki;
  kx:=dx/dT;
  ky:=dy/dU;
  SetColor(2);
   for i:=0 to r do
    begin
     x[i]:=trunc(otst+(T[i]-T_min)*kx);
     y[i]:=trunc(ymax-otst-sh_y*shag_setki+(U_max-U[i])*ky);
     circle(x[i],y[i],3);
    end;
                                   {sozdanie liniy}
  setcolor(15);
    r:=r-1;
    for i:=0 to r do
     begin
      line (x[i],y[i],x[i+1],y[i+1]);
     end;
   readln;
   closegraph;
end.
function classes(o:integer): String;
var allclasses : array[1..7] of String;
begin
    allclasses[1]:= 'class1';
    allclasses[2]:= 'class2';
    allclasses[3]:= 'class3';
    allclasses[4]:= 'class4';
    allclasses[5]:= 'class5';
    allclasses[6]:= 'class6';
    allclasses[7]:= 'class7';
    classes := allclasses[o];
end;

Above you can see a function, which should receive an integer and give a result of string that was stored in array.

procedure loadthis(chosen : string);
var f: text;
    i : integer;
begin
    Assign(f, 'files'+chosen+'.txt');
    Reset(f);
    ReadLn(f, i);
    MyChar.clas := classes[i];
end;

When this procedure is called, it calls a «classes» function. Pleae note that Mychar ir a global variable.

begin
    loadthis(FileName);
    ReadLn;
    Readln
end.

Ant this is the main program, which calls «loadthis» procedure.

I Have no idea whats wrong, but I am getting these errors:

  • Wrong amount of parameters specified
  • Illegal qualifier

Both errors come from this line:
MyChar.clas := classes[i];. I have really no idea what is wrong, maybe I can not call a function from a procedure ? Please help.

(*) С3. Сообщения синтаксического анализатора

В этом разделе описаны сообщения синтаксического анализатора. Синтаксический анализатор выполняет работу по проверке семантики вашего языка, то есть проверяет правильность языковых конструкций Pascal .

Error: Parser -Syntax Error

Ошибка Turbo Pascal была обнаружена. Это обычно происходит, если неправильный символ найден в исходном файле.

Error: INTERRUPT procedure can’t be nested

Процедура INTERRUPT должна быть глобальной.

Warning: Procedure type «Сообщение» ignored

Указанная процедурная директива игнорируется программами FPC .

Error: Not all declarations of «Сообщение» are declared with OVERLOAD

Если вы хотите использовать директиву OVERLOAD , то все объявления должны объявляться с OVERLOAD .

Error: Duplicate exported function name «Сообщение»

Экспортируемые имена функций в указанной DLL не должны совпадать.

Error: Invalid index for exported function

Индекс функции DLL должен быть в диапазоне 1..$FFFF .

Warning: Relocatable DLL or executable arg1 debug info does not work, disabled

В данный момент невозможно включить отладочную информацию в перемещаемую DLL .

Warning: To allow debugging for win32 code you need to disable relocation with -WN option

Попытка включить отладочную информацию в перемещаемую DLL или EXE — файл. Используёте ‑WN , если хотите отлаживать исполняемые файлы Win32 .

Error: Constructor name must be INIT

Вы объявили конструктор объекта, имя которого не инициализировано, а переключатель -Ss установлен. См. опцию -Ss (раздел «(*) 5.1.5. Параметры для исходных кодов (опции языка)»).

Error: Destructor name must be DONE

Вы объявили деструктор объекта, имя которого не завершено, а переключатель -Ss установлен. См. опцию -Ss (раздел «(*) 5.1.5. Параметры для исходных кодов (опции языка)»).

Error: Procedure type INLINE not supported

Вы пытаетесь компилировать программу с стилем С++ , но забыли указать опцию -Si ( -Si , см. раздел «5.1.5. Параметры для исходных кодов (опции языка)»). По умолчанию компилятор не поддерживает стиль С++ .

Warning: Constructor should be public

Конструктор должен быть в разделе public объявления объекта ( класса ).

Warning: Destructor should be public

Деструктор должен быть в разделе public объявления объекта ( класса ).

Note: Class should have one destructor only

Вы должны объявлять только один деструктор для класса.

Error: Local class definitions are not allowed

Классы должны быть объявлены глобально. Они не могут быть объявлены внутри процедуры или функции.

Fatal: Anonymous class definitions are not allowed

Было обнаружено неправильное объявление объекта ( класса ), например, объект или класс без методов, не являются рпоизводными от другого объекта. Пример:

Type o = object
a : longint ;
end ;

Note: The object «Сообщение» has no VMT

Это замечание означает, что объявленный объект не имеет таблицы виртуальных методов.

Error: Illegal parameter list

Вы вызываете функцию с параметрами, которые отличаются от параметров, указанных при объявлении функции.

Error: Wrong number of parameters specified for call to «Сообщение»

Это ошибка в списке параметров функции или процедуры – неправильное количество параметров.

Error: overloaded identifier «Сообщение» isn’t a function

Компилятор обнаружил идентификатор с именем, которое совпадает с именем перегружаемой функции, но этот идентификатор не является функцией, которая может быть перегружаемой.

Error: overloaded functions have the same parameter list

Вы объявили перегружаемые функции, но с одинаковым списком параметров. Перегружаемая функция должна иметь не менее 1 отличия в параметрах от объявленной функции.

Error: function header doesn’t match the previous declaration «Сообщение»

Вы объявили функцию с одинаковыми параметрами, но тип результата отличается.

Error: function header «Сообщ1» doesn’t match forward : var name changes Сообщ2 => Сообщ3

Вы объявили функцию в интерфейсной части, или с директивой forward, но с различным списком параметров.

Note: Values in enumeration types have to be ascending

Free Pascal допускает перечисления как в С . Проверьте следующие два объявления:

type a = ( A_A , A_B , A_E :=6, A_UAS :=200);
type a = ( A_A , A_B , A_E :=6, A_UAS :=4);

Второе объявление вызовет ошибку, потому что значение A_UAS должно быть больше, чем A_E , то есть не меньше 7.

Error: With cannot be used for variables in a different segment

Локальная переменная записывается в стек, но это невозможно, если переменная принадлежит другому сегменту.

Error: function nesting > 31

Вы можете объявлять вложенные функции только до 31 уровня в глубину.

Error: range check error while evaluating constants

Константы находятся за пределами допустимого диапазона.

Warning: range check error while evaluating constants

Константы находятся за пределами допустимого диапазона.

Error: duplicate case label

Вы указали одну и ту же метку 2 раза в конструкции case .

Error: Upper bound of case range is less than lower bound

Верхняя граница метки в конструкции case меньше, чем нижняя граница, а это неправильно.

Error: typed constants of classes or interfaces are not allowed

Вы не можете объявить константу типа класса или объекта.

Error: functions variables of overloaded functions are not allowed

Вы пытаетесь назначить перегружаемую функцию процедурной переменной. Это не допускается.

Error: string length must be a value from 1 to 255

Длина shortstring в Pascal ограничена 255 символами. Вы пытаетесь объявить строку длиной меньше 1 или больше 255 символов.

Warning: use extended syntax of NEW and DISPOSE for instances of objects

Если вы имеете указатель на объектный тип, то оператор new(a) не будет инициализировать объект (то есть конструктор не вызывается), даже если имеется свободное место для выделения памяти. Вы должны использовать оператор new(a,init) . Он выделит память и вызовет конструктор объекта.

Warning: use of NEW or DISPOSE for untyped pointers is meaningless

Использование NEW или DISPOSE для нетипизированных указателей не имеет смысла.

Error: use of NEW or DISPOSE is not possible for untyped pointers

Вы не можете использовать new(p) или dispose(p) , если p – это нетипизированный указатель, потому что для него нельзя определить размер. Это принято для совместимости с режимами TP и DELPHI , но компилятор предупредит вас, если найдёт такую конструкцию.

Error: class identifier expected

Это сообщение появляется, если компилятор обнаружил объявление процедуры, которая содержит точку, то есть метод объекта или класса, но тип перед точкой не известен компилятору.

Error: type identifier not allowed here

Вы не можете использовать тип внутри выражения.

Error: method identifier expected

Идентификатор не является методом. Это сообщение появляется, если компилятор обнаружил объявление процедуры, которая содержит точку, то есть метод объекта или класса, но имя процедуры не является процедурой данного типа.

Error: function header doesn’t match any method of this class «Сообщение»

Идентификатор не является методом. Это сообщение появляется, если компилятор обнаружил объявление процедуры, которая содержит точку, то есть метод объекта или класса, но имя процедуры не является процедурой данного типа.

Если используется переключатель -vd , то компилятор сообщает вам, когда он начинает выполнять процедуру или функцию.

Error: Illegal floating point constant

Компилятор ожидал увидеть выражение с плавающей точкой, но получил нечто другое.

Error: FAIL can be used in constructors only

Вы использовали ключевое слово fail вне метода конструктора.

Error: Destructors can’t have parameters

Вы объявили деструктор со списком параметров. Методы деструктора не могут иметь параметры.

Error: Only class methods can be referred with class references

Эта ошибка возникает в ситуации, подобной следующей:

Type :
Tclass = Class of Tobject ;
Var C : TClass ;
begin
.
C . free

Free – это не метод класса и, следовательно, не может быть вызван со ссылкой на класс.

Error: Only class methods can be accessed in class methods

Это связано похоже на предыдущую ошибку. Вы не можете вызвать метод объекта из внутреннего метода класса. Следующий код вызовет такую ошибку:

class procedure tobject . x ;
begin free

Так как free – это нормальный метод класса, он не может быть вызван из метода класса.

Error: Constant and CASE types do not match

Одна из меток конструкции CASE имеет тип, отличный от типа переменной переключателя CASE .

Error: The symbol can’t be exported from a library

Вы можете экспортировать процедуры и функции, только когда вы пишите библиотеку. Вы не можете экспортировать переменные и константы.

Warning: An inherited method is hidden by «Сообщение»

Метод, который объявлен как virtual в классе-предке, должен быть перезаписан в классе-потомке с директивой override . Если вы не укажете директиву override , вы скроете метод предка.

Error: There is no method in an ancestor class to be overridden: «Сообщение»

Вы пытаетесь переписать директивой override виртуальный метод класса- предка, который не существует.

Error: No member is provided to access property

Вы не указали директиву read для свойства.

Warning: Stored property directive is not yet implemented

Это сообщение больше не используется, так как записанная директива была выполнена.

Error: Illegal symbol for property access

Это ошибка директив read или write для свойства типа массива. Если вы объявляете свойство-массив, вы можете получить доступ к нему только с помощью процедуры или функции. Следующий код вызовет такую ошибку:

tmyobject = class
i : integer ;
property x [ i : integer ]: integer read I write i ;

Error: Cannot access a protected field of an object here

Поля, которые объявлены в разделе protected объекта или класса, не могут быть доступны из другого модуля.

Error: Cannot access a private field of an object here

Поля, которые объявлены в разделе private объекта или класса, не могут быть доступны из другого модуля.

Error: Overridden methods must have the same return type: «Сообщение2» is overriden by «Сообщение1» which has another return

Если вы объявили перегружаемые методы в определении класса, они должны иметь одинаковый тип возвращаемого результата.

Error: EXPORT declared functions can’t be nested

Вы не можете объявить функцию или процедуру внутри функции или процедуры, которая была объявлена как экспортная процедура.

Error: Methods can’t be EXPORTed

Вы не можете объявить процедуру, которая является методом для экспортируемого объекта.

Error: Call by var for arg no. Сообщ1 has to match exactly: Got «Сообщ2» expected «Сообщ3»

Если вызывающая функция объявлена с параметрами var , то переменные в вызываемой функции должны иметь точно такой же тип. Они не преобразуются автоматически.

Error: Class isn’t a parent class of the current class

Когда вызываются наследуемые методы, вы пытаетесь вызвать метод не связанный с классом. Вы можете только вызвать метод класса- предка.

Error: SELF is only allowed in methods

Вы пытаетесь использовать параметр self вне метода объекта. Только методы могут получать параметры self .

Error: Methods can be only in other methods called direct with type identifier of the class

Конструкция, подобная следующей: НекийТип.НекийМетод допускается только для методов.

Error: Illegal use of ’:’

Вы использовали формат : (двоеточие) 2 раза в выражении, которое не предусматривает такой формат.

Error: range check error in set constructor or duplicate set element

Объявление множества содержит ошибку. Какой-то элемент находится вне диапазона или имеется два одинаковых элемента.

Error: Pointer to object expected

Вы указали неправильный тип в операторе new . Расширенный синтаксис new требует параметра типа объект.

Error: Expression must be constructor call

Когда используете расширенный синтаксис new , вы должны указать метод конструктора объекта, когда пытаетесь его создать. Процедура, которую вы указали, не является конструктором.

Error: Expression must be destructor call

Когда используете расширенный синтаксис dispose , вы должны указать метод деструктора объекта, когда пытаетесь его разрушить. Процедура, которую вы указали, не является деструктором.

Error: Illegal order of record elements

При объявлении записи-константы вы указали поля в неправильном порядке.

Error: Expression type must be class or record type

Для оператора with необходим аргумент, который имеет тип записи или класса. Вы используете выражение, которое не относится ни к одному из данных типов.

Error: Procedures can’t return a value

В Free Pascal вы можете указать возвращаемое значение для функции, когда используете оператор exit . Эта ошибка случается, если вы пытаетесь сделать то же самое с процедурой. Процедура не может возвращать значение.

Error: constructors and destructors must be methods

Вы объявили процедуру как конструктор или деструктор, когда процедура не является методом класса.

Error: Operator is not overloaded

Вы пытаетесь использовать перегружаемый оператор, когда он не является перегружаемым для этого типа.

Error: Impossible to overload assignment for equal types

Вы не можете перегрузить аргумент для типов, которые компилятор рассматривает как эквивалентные.

Error: Impossible operator overload

Комбинация оператор/аргумент/возвращаемое значение является несовместимой.

Error: Re-raise isn’t possible there

Вы пытаетесь вызвать исключение там, где это недопустимо. Вы можете вызвать исключение только в блоке except .

Error: The extended syntax of new or dispose isn’t allowed for a class

Вы не можете создать экземпляр класса с расширенным синтаксисом new . Для этого должен использоваться конструктор. По тем же соображениям вы не можете использовать вызов dispose для уничтожения экземпляра класса. Для этого нужно использовать деструктор.

Error: Procedure overloading is switched off

Если используется переключатель –So , то перегрузка процедур отключена. Turbo Pascal не поддерживает перегрузку функций.

Error: It is not possible to overload this operator. Related overloadable operators (if any) are: Сообщение

Вы пытаетесь перегрузить оператор, который не может быть перегружен. Следующие операторы не могут быть перегружаемыми: +, -, *, /, =, >, =, is, as, in, **, :=

Error: Comparative operator must return a boolean value

Если перегружающий оператор – это = , то функция должна возвращать логическое значение.

Error: Only virtual methods can be abstract

Вы объявили метод как абстрактный, когда он не объявлен как виртуальный.

Fatal: Use of unsupported feature!

Вы пытаетесь форсировать компилятор, когда он к этому не готов.

Error: The mix of different kind of objects (class, object, interface, etc) isn’t allowed

Вы не можете порождать объекты, классы и интерфейсы ( objects, classes, cppclasses и interfaces ) друг от друга. Например, класс не может быть предком объекта и наоборот.

Warning: Unknown procedure directive had to be ignored: «Сообщение»

Вы указали неизвестную процедурную директиву.

Error: absolute can only be associated to one variable

Вы не можете указать более одной переменной перед директивой absolute . Таким образом, следующая конструкция вызовет эту ошибку:

Var Z : Longint ;
X , Y : Longint absolute Z ;

Error: absolute can only be associated with a var or const

Адрес директивы absolute может только указывать на переменную или константу. Таким образом, следующий код вызовет эту ошибку:

Procedure X ;
var p : longint absolute x ;

Error: Only one variable can be initialized

Вы не можете указать более одной переменной с начальным значением в режиме Delphi .

Error: Abstract methods shouldn’t have any definition (with function body)

Абстрактные методы можно только объявлять. Вы не можете их выполнить. Они должны быть перегружены в классе-потомке.

Error: This overloaded function can’t be local (must be exported)

Вы определили перегружаемую функцию в разделе implementation модуля, но она не ссылается на объявление в разделе interface .

Warning: Virtual methods are used without a constructor in «Сообщение»

Если вы определили объекты или классы, содержащие виртуальные методы, то вам необходимо иметь конструктор и деструктор для их инициализации. Компилятор нашёл объект или класс с виртуальными методами, которые не имеют пары конструктор/деструктор.

Macro defined: Сообщение

Если используется –vc , то компилятор сообщает вам, если он определяет макрос.

Macro undefined: Сообщение

Если используется –vc , то компилятор сообщает вам, если он не определяет макрос.

Macro Сообщение1 set to Сообщение2

Если используется –vc , то компилятор сообщает вам, когда макрос получает значения.

Info: Compiling Сообщение

Если вы включили информационные сообщения ( -vi ), компилятор сообщает вам, что модули перекомпилированы.

Parsing interface of unit Сообщение

Сообщение о том, что начато чтения интерфейсной части модуля.

Parsing implementation of Сообщение

Сообщение о том, что начато чтения исполняемой части модуля, библиотеки или программы.

Compiling Сообщение for the second time

Если вы запросили отладочную информацию ( -vd ), компилятор сообщает вам, что он повторно перекомпилировал модули.

Error: No property found to override

Вы хотите перегрузить свойство существующего класса-предка, но там такого свойства нет.

Error: Only one default property is allowed

Вы указали свойство как Default , но класс уже имеет свойство по умолчанию, а класс может иметь только одно такое свойство.

Error: The default property must be an array property

Только массив свойств класса может быть сделан свойствами по умолчанию.

Error: Virtual constructors are only supported in class object model

Вы не можете иметь виртуальные конструкторы в объектах. Это допускается только для классов.

Error: No default property available

Вы пытаетесь получить доступ к свойству класса по умолчанию, но этот класс (или один из его предков) не имеет свойства по умолчанию.

Error: The class can’t have a published section, use the <$M+>switch

Если вы хотите определить в классе раздел published , вы должны использовать переключатель <$M+>, который включает генерацию информации.

Error: Forward declaration of class «Сообщение» must be resolved here to use the class as ancestor

Чтобы иметь возможность использовать объект как объект-предок, его нужно сначала определить. Эта ошибка случается в следующей ситуации:

Type ParentClas = Class ;
ChildClass = Class ( ParentClass )
.
end ;

где ParentClass объявлен, но не определён.

Error: Local operators not supported

Вы не можете перегружать локальные операторы, то есть внутри определения процедуры или функции.

Error: Procedure directive «Сообщение» not allowed in interface section

Эта процедурная директива не допускается в разделе interface модуля. Вы можете использовать её только в разделе implementation .

Error: Procedure directive «Сообщение» not allowed in implementation section

Эта процедурная директива не допускается в разделе implementation модуля. Вы можете использовать её только в разделе interface .

Error: Procedure directive «Сообщение» not allowed in procvar declaration

Эта процедурная директива не может быть частью объявления процедурного типа или типа функции.

Error: Function is already declared Public/Forward «Сообщение»

Вы получите эту ошибку, если функция дважды объявлена как forward . Или если она имеется в разделе interface , а затем имеется объявление forward в разделе implementation .

Error: Can’t use both EXPORT and EXTERNAL

Эти две процедурные директивы являются взаимно исключающими.

Warning: «arg1» not yet supported inside inline procedure/function

Встроенные процедуры не поддерживают это объявление.

Warning: Inlining disabled

Встроенные процедуры отключены.

Info: Writing Browser log Сообщение

Если информационные сообщения включены, то компилятор предупреждает вас, когда записывает лог обозревателя (генерируемый переключателем <$Y+ >).

Hint: may be pointer dereference is missing

Компилятор предполагает, что указатель нужно разыменовать.

Fatal: Selected assembler reader not supported

Выбранный ассемблер (с <$ASMMODE xxx>не поддерживается. Компилятор может работать с или без поддержки редкого ассемблера.

Error: Procedure directive «Сообщение» has conflicts with other directives

Вы указали процедурную директиву, которая конфликтует с другой директивой. Например, cdecl и pascal являются взаимно исключающими, то есть несовместимыми.

Error: Calling convention doesn’t match forward

Эта ошибка случается, когда вы объявляете функцию или процедуру, например, с cdecl , но пропускаете эту директиву в разделе implementation, или наоборот. Соглашение о вызовах – это часть объявления функции, которая должна быть повторена в определении функции.

Error: The default value of a property must be constant

Значение по умолчанию объявленного свойства должно быть известно во время компиляции. Значение, которое вы указали, будет известно только во время выполнения. Эта ошибка случается, например, если вы указали имя переменной как значение по умолчанию.

Error: Symbol can’t be published, can be only a class

Только переменные типа класса могут быть в разделе published класса, если они не объявлены как свойства.

Error: This kind of property can’t be published

Свойства в разделе published не могут быть массивом. Они должны быть перемещены в раздел public . Свойства в разделе published должны быть порядкового, вещественного, строкового типа или множеством.

Error: An import name is required

Некоторые целевые платформы требуют имени для импортируемой процедуры или спецификатора cdecl .

Error: Division by zero

Было обнаружено деление на ноль.

Error: Invalid floating point operation

Операция с двумя значениями вещественного типа вызвала переполнение или деление на ноль.

Error: Upper bound of range is less than lower bound

Верхняя граница объявленного массива меньше, чем нижняя граница, а это недопустимо.

Warning: string «Сообщение1» is longer than «Сообщение2»

Размер строковой константы больше, чем размер, указанный вами при определении строкового типа.

Error: string length is larger than array of char length

Размер строковой константы больше, чем размер, указанный вами при определении Array[x..y] of char .

Error: Illegal expression after message directive

Free Pascal поддерживает только целочисленные или строковые значения в качестве констант для сообщений.

Error: Message handlers can take only one call by ref. parameter

Метод, объявленный с директивой message как обработчик сообщения, может принять только один параметр, который должен быть передан по ссылке. Параметры, передаваемые по ссылке, используют директиву var .

Error: Duplicate message label: «Сообщение»

Метка для сообщения используется дважды в одном объекте/классе.

Error: Self can only be an explicit parameter in methods which are message handlers

Параметр Self может передаваться ТОЛЬКО в метод, который объявлен как обработчик сообщения.

Error: Threadvars can be only static or global

Потоковые переменные должны быть статическими или глобальными. Вы не можете объявить локальный поток для процедуры. Локальные переменные являются всегда локальными в потоке, потому что каждый поток свой собственный стек и локальные переменные записываются в стек.

Fatal: Direct assembler not supported for binary output format

Вы не можете использовать ассемблер напрямую, если используете бинарный писатель. Вы берите другой выходной формат или используйте другой ассемблер.

Warning: Don’t load OBJPAS unit manually, use n or n instead

Вы пытаетесь загрузить модуль ObjPas вручную из раздела uses. Это плохая идея. Используйте директивы <$MODE OBJFPC>или <$mode delphi>, которые загружают этот модуль автоматически.

Error: OVERRIDE can’t be used in objects

Override не поддерживается для объектов, используйте virtual вместо этого для перегрузки метода объекта-предка.

Error: Data types which require initialization/finalization can’t be used in variant records

Некоторые типы данных (например, ansistring ) требуют кода инициализации/финализации , который полностью генерируется компилятором. Такие типы данных нельзя использовать в вариантной части записи.

Error: Resourcestrings can be only static or global

Строка ресурсов не может быть объявлена локально, только глобально или с директивой static .

Error: Exit with argument can’t be used here

Выход из блока с аргументом для возвращаемого значения не может здесь использоваться. Эта ошибка может случиться, например, в блоке try..except или try..finally .

Error: The type of the storage symbol must be boolean

Если вы указали символ storage в объявлении свойства, то оно должно быть логического типа.

Error: This symbol isn’t allowed as storage symbol

Вы не можете использовать этот типа символа как спецификатор storage в объявлении свойства. Вы можете использовать только методы результатом логического типа, логическими полями класса или логическими константами.

Error: Only classes which are compiled in $M+ mode can be published

Поле типа класса в разделе published класса может быть только классом, который был скомпилирован в <$M+>или который является потомком такого класса. Обычно такой класс должен быть потомком от TPersistent .

Error: Procedure directive expected

Эта ошибка случается, если вы имеете директиву <$Calling>без указанного условия вызова. Это также случается, если процедура объявлена в блоке констант и вы используете точку с запятой (;) после объявления процедуры, которое должна следовать за процедурной директивой. Правильное объявление:

const
p : procedure ; stdcall = nil ;
p : procedure stdcall = nil ;

Error: The value for a property index must be of an ordinal type

Значение, которое вы используете для индекса свойства, должно быть порядкового типа.

Error: Procedure name too short to be exported

Длина имени процедуры или функции должна быть не менее 2 символов. Это потому, что имеется ошибка в dlltool , который неправильно распознаёт файлы .def с именами длиной в 1 символ.

Error: No DEFFILE entry can be generated for unit global vars

Нет вхождений DEFFILE , которые могут быть сгенерированы для глобальных переменных модуля.

Error: Compile without -WD option

Вам нужно компилировать этот файл без опции –WD в командной строке.

Fatal: You need ObjFpc (-S2) or Delphi (-Sd) mode to compile this module

Вам нужно использовать <$MODE OBJFPC>или <$MODE DELPHI>для компиляции этого файла. Или использовать соответствующую опцию командной строки, любую из -objfpc или -MDelphi .

Error: Can’t export with index under Сообщение

Экспортирование функций или процедур с указанным индексом не поддерживается данной целевой платформой.

Error: Exporting of variables is not supported under Сообщение

Экспортирование переменных не поддерживается данной целевой платформой.

Error: Improper GUID syntax

Код GUID имеет неправильный синтаксис. Он должен иметь формат:

Где каждый X – шестнадцатиричное число.

Warning: Procedure named «Сообщ1» not found that is suitable for implementing the Сообщ2.Сообщ3

Компилятор не может найти подходящую процедуру, которая выполняет данный метод интерфейса. Процедура с таким именем найдена, но параметры не совпадают.

Error: interface identifier expected

Это сообщение появляется, если компилятор сканирует объявление класса, который содержит interface функции, подобно следующему:

type
TMyObject = class ( TObject , IDispatch )
function IUnknown . QueryInterface = MyQueryInterface ;
.

а interface не перечислен в списке потомков.

Error: Type «Сообщение» can’t be used as array index type

Типы, подобные qword или int64 , не допускается использовать в индексах массивов.

Error: Con-and destructors aren’t allowed in interfaces

Объявления конструктора и деструктора не допускаются в интерфейсах. В большинстве случаев метод QueryInterface интерфейса IUnknown можно использовать для создания нового интерфейса.

Error: Access specifiers can’t be used in INTERFACEs and OBJCPROTOCOLs

Спецификаторы доступности public, private, protected и published нельзя использовать в интерфейсах, Objective-C протоколов и категорий потому что все методы интерфейса /протокола/категории должны быть доступны ( public ).

The access specifiers public, private, protected and published can’t be used in interfaces, Objective-C protocols and categories because all methods of an interface/protocol/category must be public.

В спецификаторы доступа public, private, protected и published не могут быть использованы в интерфейсах, Objective-C протоколов и категорий , так как все методы интерфейсного / протокола / категории должен быть публичным.

Error: An interface can’t contain fields

Error: An interface, helper or Objective-C protocol or category cannot contain fields

Объявления полей не допускаются в интерфейсах. Интерфейс может содержать только методы и свойства с методом чтения/записи и спецификатором доступа.

Declarations of fields are not allowed in interfaces, helpers and Objective-C protocols and categories. An interface/helper/protocol/category can contain only methods and properties with method read/write specifiers.

Заявления полей не допускаются в интерфейсах, помощников и Objective-C протоколов и категорий.Интерфейс / помощник / протокол / категория может содержать только методы и свойства с помощью метода чтения / записи спецификаторов.

Error: Can’t declare local procedure as EXTERNAL

Объявление локальных процедур как внешних невозможно. Локальные процедуры получают скрытые параметры, которые делают вероятность ошибки очень высокой.

Warning: Some fields coming before «Сообщение» weren’t initialized

В режиме Delphi не все поля записи-константы могут быть инициализированы, компилятор предупреждает вас, когда обнаруживает такую ситуацию.

Error: Some fields coming before «Сообщение» weren’t initialized

Во всех режимах синтаксиса, кроме режима Delphi , вы не можете инициализировать некоторые поля в середине записи-константы.

Warning: Some fields coming after «Сообщение» weren’t initialized

Вы можете инициализировать некоторые поля в конце записи-константы (компилятор их инициализирует со значением 0 автоматически). Это может вызвать труднонаходимые проблемы.

Error: VarArgs directive (or ’. ’ in MacPas) without CDecl/CPPDecl/MWPascal and External

Директива varargs (или ‘. ‘ параметр varargs в режиме MacPas ) может использоваться только с процедурами и функциями, которые объявлены как external и одним из cdecl, cppdecl или mwpascal . Эта функциональность поддерживается только для совместимости интерфейса функций C , подобных printf .

Error: Self must be a normal (call- by-value) parameter

Вы не можете объявить Self как параметр const или var , он должен быть всега параметром, передаваемым по значению.

Error: Interface «Сообщение» has no interface identification

Если вы хотите назначить интерфейс для константы, то интерфейс должен иметь значение GUID .

Error: Unknown class field or method identifier «Сообщение»

Свойства должны ссылаться на поле или метод в этом же классе.

Warning: Overriding calling convention «Сообщение1» with «Сообщение2»

Имеются две директивы в объявлении процедуры, которые определяют соглашение о вызовах. Только последняя директива будет использоваться.

Error: Typed constants of the type «procedure of object» can only be initialized with NIL

Вы не можете связать адрес метода с типизированной константой, которая имеет тип «процедура объекта», потому что такая константа требует два адреса: для метода (который известен во время компиляции) и для объекта или класса (который неизвестен во время компиляции).

Error: Default value can only be assigned to one parameter

Невозможно указать значение по умолчанию для нескольких параметров. Следующий пример неправильный:

Procedure MyProcedure ( A , B : Integer = 0);

Вместо этого вы должны написать так:

Procedure MyProcedure ( A : Integer = 0; B : Integer = 0);

Error: Default parameter required for «Сообщение»

Указанный параметр требует значения по умолчанию.

Warning: Use of unsupported feature!

Вы пытаетесь заставить компилятор выполнить какое-либо действие, которое он пока не может выполнить.

Hint: C arrays are passed by reference

Какой-то массив, переданный в функцию С , является переданным по ссылке.

Error: C array of const must be the last argument

Вы не можете добавить какой-либо другой параметр после массива констант для функции cdecl , так как размер стека для этого параметра неизвестен.

Hint: Type «Сообщение» redefinition

Это сообщение указывает на то, что ранее объявленный тип был переопределён как-то иначе. Это может быть (а может и не быть) потенциально ошибкой исходного кода.

Warning: cdecl’ared functions have no high parameter

Функции, объявленные с модификатором cdecl , не имеют дополнительного явного параметра.

Warning: cdecl’ared functions do not support open strings

Openstring не поддерживается для функций, которые имеют модификатор cdecl .

Error: Cannot initialize variables declared as threadvar

Переменные, объявленные как threadvar , не могут быть инициализированы с значением по умолчанию. Такие переменные всегда обнуляются при старте нового потока.

Error: Message directive is only allowed in Classes

Директива message поддерживается только для типов Class .

Error: Procedure or Function expected

Метод класса может быть указан только для процедур и функций.

Warning: Calling convention directive ignored: «Сообщение»

Некоторые соглашения о вызовах поддерживаются только определёнными процессорами. Например, большинство не i386 портов поддерживаются только стандартным соглашением о вызовах ABI .

Error: REINTRODUCE can’t be used in objects

reintroduce не поддерживается для объектов. Objective-C classes and Objective-C protocols .

Error: Each argument must have its own location

Если размещение для аргументов указано явно, как того требуют некоторые соглашения системных вызовов (syscall), то каждый аргумент должен иметь своё собственное размещение. Мысли, подобные этим

procedure p ( i , j : longint ’ r1 ’);

Error: Each argument must have an explicit location

Если для одного аргумента указано явно размещение, то все аргументы процедуры должны иметь явно указанное размещение.

Error: Unknown argument location

Размещение, указанное для аргумента, не распознаётся компилятором.

Error: 32 Bit-Integer or pointer variable expected

libbase для MorphOS/AmigaOS можно получить только как переменную longint , dword или любой указатель.

Error: Goto statements aren’t allowed between different procedures

Не допускается использовать оператор goto , ссылающийся на метку, которая находится за пределами текущей процедуры. Следующий пример показывает эту проблему:

.
procedure p1 ;
label
l1 ;
procedure p2 ;
begin
goto l1 ; // Такой переход не допускается
end ;
begin
p2
l1 :
end ;
.

Fatal: Procedure too complex, it requires too many registers

Тело вашей процедуры слишком большое для компилятора. Вы должны разделить процедуру на несколько меньших процедур.

Error: Illegal expression

Это может случиться во многих ситуациях. Обычно происходит при попытке вычислить выражение с константами.

Error: Invalid integer expression

Вы написали выражение, которое не является целочисленным, а компилятор ожидал целочисленный результат.

Error: Illegal qualifier

Один из следующих вариантов:

• Вы пытаетесь получить доступ к полю переменной, которая не является записью

• Вы индексируете переменную, которая не является массивом.

• Вы разыменовываете переменную, которая не является указателем.

Error: High range limit

Вы объявили поддиапазон, где верхний предел меньше, чем нижний предел диапазона.

Error: Exit’s parameter must be the name of the procedure it is used in

Не локальный выход не допускается. Эта ошибка случается только в режиме MacPas .

Error: Illegal assignment to for-loop variable «Сообщение»

Тип переменной цикла for должен быть порядковым. Переменные цикла не могут быть строками или вещественными числами. Вы также не можете назначать значения переменным цикла внутри этого цикла (кроме режимов Delphi и TP ). Используйте циклы while или repeat вместо цикла for , если вам необходимо снять вышеописанные ограничения.

Error: Can’t declare local variable as EXTERNAL

Объявление локальных переменных как external не допускается. Только глобальные переменные могут быть связаны с внешними переменными.

Error: Procedure is already declared EXTERNAL

Процедура уже объявлена с директивой EXTERNAL в объявлении interface или forward .

Warning: Implicit uses of Variants unit

Тип Variant используется в каком-либо модуле без подключения модуля Variants . Компилятор требует явно указывать модуль Variants в разделе uses . Для удаления этого сообщения модуль Variants должен быть добавлен в список модулей в разделе uses .

Error: Class and static methods can’t be used in INTERFACES

Спецификатор class и директива static не могут использоваться в интерфейсах, потому что все методы интерфейса должны быть общедоступными.

Error: Overflow in arithmetic operation

Операция с двумя целочисленными значениями вызвала переполнение.

Error: Protected or private expected

strict можно использовать только совместно с protected или private .

Error: SLICE can’t be used outside of parameter list

slice можно использовать только для аргументов, принимающих параметр открытого массива.

Error: A DISPINTERFACE can’t have a parent class

DISPINTERFACE – это специальный тип интерфейса, который не может иметь класса-предка.

Error: A DISPINTERFACE needs a guid

DISPINTERFACE всегда требует идентификации интерфейса ( GUID ).

Warning: Overridden methods must have a related return type. This code may crash, it depends on a Delphi parser bug

Если вы объявили перегружаемые методы в определении класса, они должны иметь одинаковый тип возвращаемого результата. Некоторые версии Delphi позволяют изменять тип возвращаемого результата методов интерфейса, и даже заменять процедуры на функции, но в результате код может оказаться неработоспособен на используемых типах и вызываемых методах.

Error: Dispatch IDs must be ordinal constants

Ключевое слово dispid должно следовать за константой порядкового типа (индекс dispid ).

Error: The range of the array is too large

Несмотря на правильно указанный размер, количество элементов в массиве не может быть более чем high(ptrint) . Кроме того, тип, определяющий диапазон массива, должен быть поддиапазоном ptrint .

Error: The address cannot be taken of bit packed array elements and record fields

Если вы объявили массив или запись как packed в режиме Mac Pascal (или как packed в любом режиме с <$bitpacking on>), то он будет запакован до битового уровня. Это означает, что невозможно будет получить индивидуальный адрес элемента массива или поля записи. Исключение из этого правила возможно только в том случае, если размер упаковки кратен 8.

Error: Dynamic arrays cannot be packed

Только стандартные (и возможно в будущем – открытые) массивы могут быть упакованы.

Error: Bit packed array elements and record fields cannot be used as loop variables

Если вы объявили массив или запись как packed в режиме Mac Pascal (или как packed в любом режиме с <$bitpacking on>), то он будет запакован до битового уровня. Это означает, что для работы с таким массивом нельзя будет использовать циклы.

Error: VAR and TYPE are allowed only in generics

Использование VAR и TYPE для объявлений новых типов допускается только внутри generics .

Error: This type can’t be a generic

Только классы, объекты, интерфейсы и записи могут использоваться как generic .

Warning: Don’t load LINEINFO unit manually, Use the -gl compiler switch instead

Не используйте модуль lineinfo напрямую. Используйте переключатель ‑gl , который правильно и автоматически добавляет этот модуль для чтения выбранного типа отладочной информации. Модуль, который требуется для использования отладочной информации соответствующего типа, используется, когда компилируется бинарный файл.

Error: No function result type specified for function «Сообщение»

Когда вы объявляете функцию первый раз, вы должны объявлять её в полной форме, то есть со всеми параметрами и типом результата.

Error: Specialization is only supported for generic types

Типы, не являющиеся generics , не могут быть специализированы.

Error: Generics can’t be used as parameters when specializing generics

Если специализация generic, то только не-generic типы могут использоваться как параметры.

Error: Constants of objects containing a VMT aren’t allowed

Если объект требует VMT , потому что он содержит конструктор или виртуальные методы, то не допускается создавать в нём константы. В режимах TP и Delphi это разрешено для совместимости.

Error: Taking the address of labels defined outside the current scope isn’t allowed

Не допускается брать адрес метки за пределами текущей процедуры.

Error: Cannot initialize variables declared as external

Переменные, объявленные как external , не могут быть инициализированы значением по умолчанию.

Error: Illegal function result type

Некоторые типы, например, файловые, не могут использоваться как результат, возвращаемый функцией.

Error: No common type possible between «Сообщ1» and «Сообщ2»

Для выполнения операций с целыми числами компилятор преобразовал оба операнда в их общий тип, который оказался неправильным. Для определения общего типа операндов, компилятор берёт минимум из минимальных значений обоих типов, а затем максимум из максимальных значений обоих типов. Общий тип получается минимум..максимум .

Error: Generics without specialization cannot be used as a type for a variable

Generics должен быть всегда специализирован перед использованием как тип переменной.

Warning: Register list is ignored for pure assembler routines

Если используется чисто ассемблерная процедура, то список с изменёнными регистрами игнорируется.

Error: Implements property must have class or interface type

Свойство, которое принадлежит интерфейсу, должно быть типа класса или интерфейса.

Error: Implements-property must implement interface of correct type, found «Сообщ1» expected «Сообщ2»

Свойство, которое принадлежит интерфейсу, на самом деле принадлежит другому интерфейсу.

Error: Implements-property must have read specifier

Свойство, которое принадлежит интерфейсу, должно иметь, по меньшей мере, спецификатор read .

Error: Implements-property must not have write-specifier

Свойство, которое принадлежит интерфейсу, может не иметь спецификатор write .

Error: Implements-property must not have stored-specifier

Свойство, которое принадлежит интерфейсу, может не иметь спецификатора stored .

Error: Implements-property used on unimplemented interface: «Сообщение»

Интерфейс, которому принадлежит свойство, не принадлежит классу.

Error: Floating point not supported for this target

Компилятор проанализировал выражение с плавающей точкой, но оно не поддерживается.

Error: Class «Сообщ1» does not implement interface «Сообщ2»

Делегированный интерфейс не принадлежит классу, данному в разделе implements .

Error: Type used by implements must be an interface

Ключевое слово implements должно применяться с типом interface .

Error: Variables cannot be exported with a different name on this target, add the name to the declaration using the «export»

На большинстве целевых платформ невозможно изменять имена, под которыми переменные экспортируются внутри операторов exports библиотеки. В таком случае вам нужно указать экспортируемое имя в точке, где объявлена переменная, используя export и директиву alias .

Error: Weak external symbols are not supported for the current target

Символ » weak external » – это символ, который может существовать, а может и нет (при static или dynamic ) во время компоновки. Эта концепция может быть недоступна (или ещё не работать) на текущей платформа или процессоре.

Error: Forward type definition does not match

Классы и интерфейсы с объявлением forward должны иметь одинаковые типы с implemented . Интерфейс forward не может быть изменён в классе.

Note: Virtual method «Сообщ1» has a lower visibility (Сообщ2) than parent class Сообщ3 (Сообщ4)

Виртуальный метод перегружает метод, который объявлен с более высокой видимостью. Это может дать непредвиденные результаты.

Error: Fields cannot appear after a method or property definition, start a new visibility section first

Однажды определив метод или свойство в классе или объекте, вы не можете определить какие-либо поля впоследствии без начального раздела видимости (такого как public , private и т.п.).

The reason is that otherwise the source code can appear ambiguous to the compiler, since it is possible to use modifiers such as default and register also as field names.

Причина в том, что в противном случае исходный код может оказаться неоднозначной в компилятор, так как можно использовать модификаторы, такие как умолчанию и регистрации также в качестве имен полей.

Error: Parameters cannot contain local type definitions. Use a separate type definition in a type block.

В Pascal нельзя передавать определения типов в качестве параметров, даже если они семантически эквивалентны простым типам. Переменные или параметры должны быть одинакового типа, если они ссылаются на определения одинаковых типов. В результате это не позволяет объявлять новые типы внутри списка параметров, потому что тогда возможны ссылки на то же определение типа в заголовке процедуры в разделах interface и implementation модуля (оба заголовка процедуры определены с разными типами). Помните, что выражения, такие как “ file of byte ” или “ string[50] ” также должны определяться как новый тип. Например, вы не можете объявить процедуру:

Procedure MyProc ( st : string [50]);

Это приведёт к данной ошибке. Правильно будет так:

Type TMyStr = string [50];
Procedure MyProc ( st : TMyStr );

Error: ABSTRACT and SEALED conflict

ABSTRACT и SEALED не могут использоваться вместе в одном объявлении.

Error: Cannot create a descendant of the sealed class «Сообщение»

Неизвестный метод этого класса не может быть унаследован другим классом.

Error: SEALED class cannot have an ABSTRACT method

Неизвестный метод этого класса не может быть унаследован. Следовательно, ни один класс не способен перегрузить абстрактный метод в неизвестном классе.

Error: Only virtual methods can be final

Вы объявили метод как финальный, когда он не объявлен как виртуальный.

Error: Final method cannot be overridden: «Сообщение»

Вы пытаетесь перегрузить виртуальный метод родительского класса, который не существует.

Error: Invalid enumerator identifier: «Сообщение»

Только идентификаторы перечислений » MoveNext » и » Current » поддерживаются.

Error: Enumerator identifier required

Идентификатор » MoveNext » или » Current » должен сопровождать модификатор нумератора.

Error: Enumerator MoveNext pattern method is not valid.

Метод должен быть функцией с результатом типа Boolean , а соответствующий нумератор » MoveNext » должен быть функцией с результатом типа Boolean и не требовать аргументов.

Error: Enumerator Current pattern property is not valid. Property must have a getter.

Нумератор » Current » соответствующего свойства должен быть больше.

Error: Only one enumerator MoveNext method is allowed per class/object

Класс или объект может иметь только один нумератор MoveNext .

Error: Only one enumerator Current property is allowed per class/object

Класс или объект может иметь только один нумератор Current .

Error: For in loop cannot be used for the type «Сообщение»

For в цикле может использоваться не для всех типов. Например, он не может использоваться для нумераторов.

Error: Objective-C messages require their Objective-C selector name to be specified using the ”message” directive.

Objective-C messages require their Objective-C name (selector name) to be specified using the message ‘someName:’ procedure directive. While bindings to other languages automatically generate such names based on the identifier you use (by replacing all underscores with colons), this is unsafe since nothing prevents an Objective-C method name to contain actual colons.

Objective-C сообщения требуют свое имя Objective-C (имя селектора), который будет указан с помощью сообщения ‘SomeName:’ Директива процедура. Хотя привязки на другие языки автоматически генерировать такие имена, основанные на идентификатор вы используете (путем замены всех подчеркивает двоеточиями), это небезопасно, так как ничто не мешает Objective-C имя метода, чтобы содержать фактические двоеточия.

Error: Objective-C does not have formal constructors nor destructors. Use the alloc, initXXX and dealloc messages.

The Objective-C language does not have any constructors or destructors. While there are some messages with a similar purpose (such as init and dealloc), these cannot be identified using automatic parsers and do not guarantee anything like Pascal constructors/destructors (e.g., you have to take care of only calling “designated” inherited “constructors”). For these reasons, we have opted to follow the standard Objective-C patterns for instance creation/destruction.

Язык Objective-C не имеет конструкторов и деструкторов. Хотя есть некоторые сообщения, с той же целью (например, инициализации и dealloc), они не могут быть определены с помощью автоматических анализаторов и ничего не гарантирует, как Pascal конструкторов / деструкторов (например, вы должны заботиться о только называя «назначен» в наследство «конструкторы «). По этим причинам, мы решили следовать стандартным образцам Objective-C, например создания / уничтожения.

Error: Message name is too long (max. 255 characters)

Due to compiler implementation reasons, message names are currently limited to 255 characters

Error: Objective-C message symbol name for ”arg1” is too long

Due to compiler implementation reasons, mangled message names (i.e., the symbol names used in the assembler code) are currently limited to 255 characters.

Hint: Defining a new Objective-C root class. To derive from another root class (e.g., NSObject), specify it as the parent class.

If no parent class is specified for an Object Pascal class, then it automatically derives from TObject. Objective-C classes however do not automatically derive from NSObject, because one can have multiple root classes in Objective-C. For example, in the Cocoa framework both NSObject and NSProxy are root classes. Therefore, you have to explicitly define a parent class (such as NSObject) if you want to derive your Objective-C class from it.

Error: Objective-C classes cannot have published sections.

In Object Pascal, “published” determines whether or not RTTI is generated. Since the Objective-C runtime always needs RTTI for everything, this specified does not make sense for Objective-C classes.

Fatal: This module requires an Objective-C mode switch to be compiled

This error indicates the use of Objective-C language features without an Objective-C mode switch active. Enable one via the -M command line switch, or the $modeswitch x directive.

Error: Inherited methods can only be overridden in Objective-C, add ”override” (inherited method defined in arg1)

Hint: Inherited methods can only be overridden in Objective-C, add ”override” (inherited method defined in arg1)

It is not possible to reintroduce methods in Objective-C like in Object Pascal. Methods with the same name always map to the same virtual method entry. In order to make this clear in the source code, the compiler always requires the override directive to be specified when implementing overriding Objective-C methods in Pascal. If the implementation is external, this rule is relaxed because Objective-C does not have any override-style keyword (since it’s the default and only behaviour in that language), which makes it hard for automated header conversion tools to include it everywhere. The type in which the inherited method is defined is explicitly mentioned, because this may either be an objcclass or an objccategory.

Error: Message name ”arg1” in inherited class is different from message name ”arg2” in current class.

An overriding Objective-C method cannot have a different message name than an inherited method. The reason is that these message names uniquely define the message to the Objective-C runtime, which means that giving them a different message name breaks the “override” semantics.

Error: It is not yet possible to make unique copies of Objective-C types

Duplicating an Objective-C type using type x = type y; is not yet supported. You may be able to obtain the desired effect using type x = objcclass(y) end; instead.

Error: Objective-C categories and Object Pascal class helpers cannot be used as types

It is not possible to declare a variable as an instance of an Objective-C category or an Object Pascal class helper. A category/class helper adds methods to the scope of an existing class, but does not define a type by itself. An exception of this rule is when inheriting an Object Pascal class helper from another class helper.

Error: Categories do not override, but replace methods. Use ”reintroduce” instead.

Error: Replaced methods can only be reintroduced in Objective-C, add ”reintroduce” (replaced method defined in arg1).

Hint: Replaced methods can only be reintroduced in Objective-C, add ”reintroduce” (replaced method defined in arg1).

A category replaces an existing method in an Objective-C class, rather than that it overrides it. Calling an inherited method from an category method will call that method in the extended class’ parent, not in the extended class itself. The replaced method in the original class is basically lost, and can no longer be called or referred to. This behaviour corresponds somewhat more closely to reintroduce than to override (although in case of reintroduce in Object Pascal, hidden methods are still reachable via inherited). The type in which the inherited method is defined is explicitly mentioned, because this may either be an objcclass or an objccategory.

Error: Getter for implements interface must use the target’s default calling convention.

Interface getters are called via a helper in the run time library, and hence have to use the default calling convention for the target (register on i386 and x86_64, stdcall on other architectures).

Error: Typed files cannot contain reference-counted types.

The data in a typed file cannot be of a reference counted type (such as ansistring or a record containing a field that is reference counted).

Error: Operator is not overloaded: arg2 ”arg1”

You are trying to use an overloaded operator when it is not overloaded for this type.

Error: Operator is not overloaded: ”arg1” arg2 ”arg3”

You are trying to use an overloaded operator when it is not overloaded for this type.

Error: Expected another arg1 array elements

When declaring a typed constant array, you provided to few elements to initialize the array

Error: String constant too long while ansistrings are disabled

Only when a piece of code is compiled with ansistrings enabled (<$H+>), string constants longer than 255 characters are allowed.

Error: Type cannot be used as univ parameter because its size is unknown at compile time: ”arg1”

univ parameters are compatible with all values of the same size, but this cannot be checked in case a parameter’s size is unknown at compile time.

Error: Only one class constructor can be declared in class: ”arg1”

You are trying to declare more than one class constructor but only one class constructor can be declared.

Error: Only one class destructor can be declared in class: ”arg1”

You are trying to declare more than one class destructor but only one class destructor can be declared.

Error: Class constructors can’t have parameters

You are declaring a class constructor with a parameter list. Class constructor methods cannot have parameters.

Error: Class destructors can’t have parameters

You are declaring a class destructor with a parameter list. Class destructor methods cannot have parameters.

Fatal: This construct requires the <$modeswitch objectivec1>mode switch to be active

Objective-Pascal constructs are not supported when <$modeswitch ObjectiveC1>is not active.

Error: Unicodechar/string constants cannot be converted to ansi/shortstring at compile-time

It is not possible to use unicodechar and unicodestring constants in constant expressions that have to be converted into an ansistring or shortstring at compile time, for example inside typed constants. The reason is that the compiler cannot know what the actual ansi encoding will be at run time.

Error: For-in Objective-Pascal loops require <$modeswitch ObjectiveC2>to be active

Objective-C “fast enumeration” support was added in Objective-C 2.0, and hence the appropriate modeswitch has to be activated to expose this feature. Note that Objective-C 2.0 programs require Mac OS X 10.5 or later.

Error: The compiler cannot find the NSFastEnumerationProtocol or NSFastEnumerationState type in the CocoaAll unit

Objective-C for-in loops (fast enumeration) require that the compiler can find a unit called CocoaAll that contains definitions for the NSFastEnumerationProtocol and NSFastEnumerationState types. If you get this error, most likely the compiler is finding and loading an alternate CocoaAll unit.

Error: Typed constants of the type ’procedure is nested’ can only be initialized with NIL and global procedures/functions

A nested procedural variable consists of two components: the address of the procedure/function to call (which is always known at compile time), and also a parent frame pointer (which is never known at compile time) in case the procedural variable contains a reference to a nested procedure/function. Therefore such typed constants can only be initialized with global functions/procedures since these do not require a parent frame pointer.

Fatal: Declaration of generic class inside another generic class is not allowed

At the moment, scanner supports recording of only one token buffer at the time (guarded by internal error 200511173 in tscannerfile.startrecordtokens). Since generics are implemented by recording tokens, it is not possible to have declaration of generic class inside another generic class.

Error: Forward declaration of objcprotocol ”arg1” must be resolved before an objcclass can conform to it

An objcprotocol must be fully defined before classes can conform to it. This error occurs in the following situation:

Type MyProtocol = objcprotoocl;

where MyProtocol is declared but not defined.

Error: Record types cannot have published sections

Published sections can be used only inside classes.

Error: Destructors aren’t allowed in records or helpers

Destructor declarations aren’t allowed in records or helpers.

Error: Class methods must be static in records

Class methods declarations aren’t allowed in records without static modifier. Records have no inheritance and therefore non static class methods have no sence for them.

Error: Constructors aren’t allowed in records or record helpers

Constructor declarations aren’t allowed in records or record helpers

Error: Either the result or at least one parameter must be of type ”arg1”

It is required that either the result of the routine or at least one of its parameters be of the specified type. For example class operators either take an instance of the structured type in which they are defined, or they return one.

Error: Type parameters may require initialization/finalization — can’t be used in variant records

Type parameters may be specialized with types which (e.g. ansistring) need initialization/finalization code which is implicitly generated by the compiler.

Error: Variables being declared as external cannot be in a custom section

A section directive is not valid for variables being declared as external

Error: Non-static and non-global variables cannot have a section directive

A variable placed in a custom section is always statically allocated so it must be either a static or global variable.

Error: ”arg1” is not allowed in helper types

Some directives and specifiers like ”virtual”, ”dynamic”, ”override” aren’t allowed inside helper types in mode ObjFPC (they are ignored in mode Delphi), because they have no meaning within helpers. Also ”abstract” isn’t allowed in either mode.

Error: Class constructors aren’t allowed in helpers

Class constructor declarations aren’t allowed in helpers.

Error: The use of ”inherited” is not allowed in a record

As records don’t suppport inheritance the use of ”inherited” is prohibited for these as well as for record helpers (in mode ”Delphi” only).

Error: Type declarations are not allowed in local or anonymous records

Records with types must be defined globally. Types cannot be defined inside records which are defined in a procedure or function or in anonymous records.

Error: Duplicate implements clause for interface ”arg1”

A class may delegate an interface using the ”implements” clause only to a single property. Delegating it multiple times is a error.

Error: Interface ”arg1” can’t be delegated by ”arg2”, it already has method resolutions

Method resolution clause maps a method of an interface to a method of the current class. Therefore the current class has to implement the interface directly. Delegation is not possible.

Error: Interface ”arg1” can’t have method resolutions, ”arg2” already delegates it

Method resoulution is only possible for interfaces that are implemented directly, not by delegation.

Источник







Deutsch (de)
English (en)

español (es)


français (fr)



日本語 (ja)




português (pt)

русский (ru)
slovenčina (sk)






This page is about how to port or convert existing Delphi or Kylix code to work with the Free Pascal Compiler and Lazarus IDE. While Lazarus and the Free Pascal Compiler have aspects in common with Delphi and Kylix, they are not clones. There are a number of library call and convention differences… and in some areas, FPC is enhanced and can be more demanding about correct syntax. Please see the Lazarus For Delphi Users guide for a description of some of the functional differences.

The purpose of this guide is to document some of the specific differences that are frequently encountered during the code conversion process when translating existing code from Delphi to Lazarus.

This document was placed into the wiki knowledge-base area so it could be easily extended by anyone who had encountered a unique problem and would like to post it for others to be aware of.

Selecting a component or library for conversion

Where to find code to convert

There is a LOT of code available on the net that can be converted for use with FPC and Lazarus. Here is a Page Of Code Sites that is just a start. Please add to it if you know of any other good locations. TurboPower Software has recently released their entire commercial offering under the MPL. A list of available packages can be found here.

To avoid duplicating effort, packages that have already been converted are listed on the Components and Code examples page. If you’ve converted a package or are working on one, please add a note on the Current conversion projects page.

Licensing

Licenses for existing code range from freeware/public domain to restrictive versions that prohibit modification, re-distribution and commercial use. Before converting any package, it’s a good idea to examine its licensing and make sure it’s going to be compatible with Lazarus and the Free Pascal Compiler. License selection is especially important with components since dropping one on a form can impose an unwanted or incompatible license on an entire application.

When converting components, please respect the wishes of the original author and retain all copyright and licensing headers along with email addresses and url’s. It’s courteous and often useful to inform the author that their component is being converted… especially if the component is under a restrictive license. New interest in an old or forgotten component can sometimes inspire authors to revise their original and overly restrictive licensing.

In general, Public Domain (freeware), and the LGPL/MPL are the the most flexible for distributing components. For more information, the Open Source Definition is a good place to start. There are also several comparisons available to help clarify how the various types of licenses work and what impact they’ll have on code they’re linked to. Search for «open source license comparison»

Dependencies

Another step before starting to work on a conversion is to verify that the code doesn’t have deep dependancies on other packages that might not be available or represent a considerable conversion challenge. Some freeware offerings are bound to or extend proprietary packages that are frequently no longer available or come with inappropriate licenses.

Compiler Issues

See:

  • Known problems
  • Unfixed bugs

Platform and OS Issues

Lazarus and the Free Pascal Compiler are cross-platform and cross-architecture development tools. In contrast, most existing Delphi code was specifically designed to run on an Intel processor under Win32. If your candidate component has a lot of Win32 specific code, it might be wise to try and find a less platform dependant alternative. But don’t let this stop you… it’s genuinely amazing what the LCL supports!

Doing the conversion

Setting up the Lazarus environment for a conversion project

Create a test project

  • Place code to be converted into a subdirectory (ie: convertdir)
  • Bring up Lazarus
  • File->Save All to the convertdir subdirectory. Meaningful names for the Project and default unit are optional.
  • Open the «main» unit to be converted in convertdir
  • Add it to the project: Project->Add Active Unit to Project
  • Run Tools->Quick Syntax Check or Run Build All to get started.

Initial items to watch out for

  • Filenames are case sensitive with the 1.0.x series compilers. If you’re working with this version, make all your filenames lower case. You’ll get «File not found» errors if you don’t.

Delphi VCL, Kylix CLX Sources in Lazarus

When converting Delphi/Kylix sources, it is often useful to do a find declaration to see, what a specific function is doing. The Lazarus IDE can parse the Delphi/Kylix sources. To do this it needs some searchpaths and compiler settings. You can easily setup this in
Environment->CodeTools Defines Editor->Insert Template

Conversion problems and solutions

Delphi / Kylix file equivalents in Lazarus

Delphi / Kylix Description Lazarus Description
.pas

.dfm/.xfm,

.dcu/.dpu,

.dpr(main project file),

.res,

.dof/.kof

Delphi Source File,

Delphi Form,

Delphi Compiled Unit,

Delphi Project,

Windows Resource File,

Delphi Option File

.pas, .pp

.lfm,

.o,

.lpr

.lrs,

.lpi(main project file),

.ppu

Pascal unit file,

Form data file,

Compiled unit file,

Project file,

Resource file,

Project options file,

Lazarus resource file,

Lazarus project information file,

FPC unit description file

So a Delphi .dcu file roughly corresponds to a FPC .o and .ppu together in one file. The .PPU is mostly the header(interface) part, the .o mostly the implementation part. Main exceptions are inlined functions, that in to-be-inlined form are in the .ppu.

Converting Delphi projects/forms/units to Lazarus

Use the Delphi converter in new Lazarus version to convert automatically. It does most of the things explained later on this page. More information here: Delphi Converter in Lazarus

The following text explains the differences between Delphi and Lazarus and how to convert manually.

Selecting the right compiler mode

The Free Pascal Compiler supports 5 different pascal modes. For example TP for turbo pascal, lets you compile turbo pascal units. There is also a DELPHI compatibility mode that can be set to make existing code easier to convert. Lazarus prefers the OBJFPC mode, which almost equals the DELPHI mode, but is less ambiguous than the Delphi syntax. Here are the important points:

The mode can be selected at command line or at the start of the source. Using the command line has the advantage, that you don’t need to change the source, but the disadvantage, that others must be told.

Most Delphi units can be compiled by the Free Pascal compiler by adding:

{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}

right after the unit name.

For more details about Free Pascal modes see the Free Pascal Documentation

Cross-Platform considerations

  • Inline assembler is always a problem because it will bind the code to the Intel architecture. Some developers do algorithm prototypes in Pascal and ifdef the their optimized assembler. Fortunately TurboPower did this in numerous places with their code. If this is the case with the package you’re converting, throw the switch back to Pascal.
  • Don’t reference specific memory location like the BIOS data area. Find out what the code needs and try to find a cross platform alternative.
  • Don’t do processor specific tricks (like using the Intel TSC) without enclosing your code in an ifdef for the platform the code needs… and providing an alternative for environments that don’t have the hardware capability.
  • If you need some OS specific code, then you can use IFDEFs. See below for a list of macros.

Useful compiler variables / defines / macros

To write code, that behaves on different systems differently, you can use the

{$IFDEF Name}

directives.

  • {$IfDef FPC}

This variable is defined, when using the FPC compiler. Useful to write code, that works with FPC and Delphi. For compatibility reasons FPC defines the DELPHI macro in mode Delphi. So you can not use
{$IFNDEF DELPHI}.

  • {$IfDef FPC_OBJFPC}

This variable is defined when using mode OBJFPC and can be a substitute for {$IFNDEF Delphi} for e.g. the @ differences

  • {$IfDef LCL}

This variable is defined, when using the LCL package. Useful to write code, that works with the LCL and Delphi.

  • {$IfDef LCLGtk}

    ,

    {$IfDef LCLWin32}

    ,

    {$IfDef LCLQt}

    , …

This variable is defined, when using the LCL package and the specific widgetset is currently used. Useful to write code, that works with the LCL on a specific platform.

  • {$IfDef Unix} // for Linux, BSD, macOS, Solaris

    ,

    {$IfDef Win32}

    ,

    {$IfDef Linux}

    // for Linux,

    {$IfDef Darwin}

    // macOS,

    {$IfDef WinCE}

    // for WinCE,…

Defined by FPC for the current Target OS. Delphi defines «Linux», «Win32» and «MSWindows». Free Pascal runs on much more platforms and so it is recommended to use the more general items. For example «Unix» is defined for Linux, FreeBSD, NetBSD and OpenBSD, where Lazarus already runs.
Use for code that should work with Delphi and FPC:

{$IFDEF Linux}
{$DEFINE Unix}
{$ENDIF}

to work around this for Kylix.

  • {$IfDef ENDIAN_BIG}

This macro is defined on big endian processors such as the PowerPC as used, a.o., in older Apple computers. Their byte order is the reverse of that of Intel compatible processors.

  • {$IfDef ENDIAN_BIG}

For more details see the Free Pascal Documentation.

32bit / 64 bit support

Pointers under 64bit need 8 bytes instead of 4 on 32bit. The ‘Integer’ type remains for compatibility 32bit. This means you can no longer typecast pointers into integers and back. FPC defines two new types: PtrInt and PtrUInt. PtrInt is a 32bit signed integer on 32 bit platforms and a 64bit signed integer on 64bit platforms. The same for PtrUInt, but unsigned integer instead.
Use for code that should work with Delphi and FPC:

{$IFNDEF FPC}
type
PtrInt = integer;
PtrUInt = cardinal;
{$ENDIF}

Replace all integer(SomePointerOrObject) with PtrInt(SomePointerOrObject).

For more information see Multiplatform Programming Guide.

Finding a missing identifier

There are differences in how the LCL is organized when compared to the Delphi VCL. If you get a «not found» compiler error about a major class or identifier, the chances are good that it’s in a different unit. A complete cross reference can be found by grep’ing lazarus/docs/xml or the lcl subdirectory.

For example the commonly used tbutton typically throws an error in Delphi code because it’s located in a unit named buttons.pp. The following command finds the correct unit very quickly (in the lazarus source directory):

grep -in ' tbutton =' lcl/*

Major unit differences between Lazarus and Delphi

Please add to this topic!

  • Windows->Interfaces, LCLIntf, LCLType, LCLProc, …)

As the LCL is not windows specific, the code that is in the Delphi Windows unit for directly accessing the Win32 API is abstracted into separate interfaces, which can be accessed from the LCLIntf unit. Keep in mind, that Lazarus does not emulate win32, so many functions are missing and some do not work as their win32 counterparts. These functions only exist for Delphi compatibility and should only be used for quick & dirty porting. LCL also breaks out many of the types, so often LCLType is required. LCLProc also contains a few functions which can be useful for lower level handling such as «FreeThenNil» as is in Delphi 5 and higher, «DeleteAmpersands» to remove additional ampersands from a string for controls(& vs && etc). The Interfaces unit needs to be included in the .lpr file to initialize the appropriate widgetset.

  • Messages->LMessages

TControl Messages for win32 event callbacks of the format WM_CALLBACK and the structs associated with them are often found in the Messages unit in Delphi. In the LCL these types of messages and there structs are usually found in LMessages, usually with name changes of WM to LM, so for instance WM_MOUSEENTER becomes LM_MOUSEENTER, and TWMMouse becomes TLMMouse.

  • Graphics, Controls->GraphType, GraphMath, Graphics, Controls

To simplify some things and break complexity of circles between units, a few types have been abstracted into a shared unit called GraphType, which includes things, which in Delphi are located in Graphics or Controls, for instance the bvNone etc of panels. So sometimes you have to include it. Also a unit which, although incompatible with Delphi, adds other useful functionality is GraphMath, which adds a TFloatPoint for precision, misc routines for dealing with beziers, lines, and arcs, as well as some operator overloading for use with TPoints and TRect, such as for instance Point1 := Point2 + Point3, and comparing two rects like if (rect1 = rect2) then …

  • Mask->MaskEdit

For more intelligent naming considerations, the unit for TMaskEdit is called [MaskEdit|] instead of the slightly more nebulous Mask as in many versions of Delphi.

  • StdCtrls->StdCtrls,Buttons

In many version of Delphi TButton is located in StdCtrls, while TSpeedButton and TBitBtn are in Buttons. For consistency and simplicity the LCL puts all button types in Buttons, which can occasionally break code conversion, so it is always a good idea to include.

Property and method differences Delphi -> FPC/LCL

  • TBitmap contains a canvas in the LCL
  • Lazarus_Faq#Why are TForm.ClientWidth.2FClientHeight the same as TForm.Width.2FHeight

Semantical differences

Order of parameter evaluation

Delphi guarantees that all parameters are evaluated from left to right. FPC makes no such guarantee, and can evaluate parameters in any order it wants in order to generate optimal code.

Nested procedures/functions as procedural variables

Delphi passes the framepointer of the parent procedure always on the stack, and has the caller remove it again. This means that as long as you do not access variables from a parent procedure, you can pass the address of a nested function to another function which then can call it like any other procedural variable.

FPC on the other hand always passes the framepointer of the parent procedure as a hidden first parameter according to the current calling convention, which means that if you call a nested procedure like a regular procedural variable, all parameters will be «shifted» one position.

In short, do not call nested procedures via procedural variables.

Ref count release

Documented behaviour in both Delphi and FPC is that temporary variables stay allocated till after the statement of last use. (so if an interface is used in a parameter declaration, it is earliest released after that whole procedure/method call statement has finished).

However in practice FPC often indeed decreases the refcount the very next statement, while Delphi tends to wait till the end of procedures. Or, in very large procedures, till the end of a large block.

Both are valid choices though, and fixating this behaviour would hem in the codegeneration and optimizer too much, and it won’t changed.

This can occasionally cause apparently working Delphi code that mixes object and interface references to fail, and is a typical case of seemingly working code not being correct and depending on implementation choices. The Delphi documentation doesn’t make any such guarantees.

Syntax differences

Please add to this topic!

Because of the inherent strictness in FPC, some syntax changes are necessary, even though

{$Mode Delphi}

does allow more laziness like Delphi does. For this reason complying as much with the syntax rules of

{$Mode ObjFPC}

as possible is highly recommended, even when the codebase is still going to be shared between Delphi and the LCL. Some of these are simply better coding practices, and sometimes because Delphi mode is not entirely accurate, or in a few instances Delphi acceptible code does not function as expected with FPC, even though it might compile. To that end even though not all such are strictly required, the following list of changes should be considered mandatory :

When assigning an event handling entry point, prefix it with an «@»

For instance, you might assign a button callback manually.

With the Delphi code compiled under Lazarus You will get the error message
"Wrong number of parameters specified for call to "SomeFunction" "
Delphi OBJFPC both
begin
if not Assigned(MyButton.OnClick) then 
MyButton.OnClick:= SomeFunction;
//@ not required
//more code...
end;
begin
if not Assigned(MyButton.OnClick) then
MyButton.OnClick:= @SomeFunction;
//@ IS required
//more code...
end;
begin
if not Assigned(MyButton.OnClick) then
MyButton.OnClick:= {$IFDEF FPC_OBJFPC}@{$ENDIF}SomeFunction;
//@ is only required under mode OBJFPC - but not allowed under Delphi
//more code...
end;

Note that this behavior of the compiler can also be influenced using the CLASSICPROCVARS modeswitch.

When calling a procedure variable use this syntax: theprocname()

In Delphi there is no difference between a function result and a variable, however there is in FPC, so to call a function, even if it has no parameters, you must append parenthesis.

With the Delphi code compiled under Lazarus You will get the error message
"Incompatible types: got "<procedure variable type of function:DWord;StdCall>" expected "LongWord" "
Delphi OBJFPC both
With (SomeObject) do 
begin
If Assigned(OnMyCallback) then
OnMyCallback;
//parenthesis not required
end;
With (SomeObject) do 
begin
If Assigned(OnMyCallback) then
OnMyCallback();
//parenthesis required
end;
Simply use the OBJFPC way, with brackets:
OnMyCallback();
Delphi accepts this, too.
When accessing values in a pointer to a record you must dereference first

In Delphi it is not required to de-reference a pointer to a record to access values within it, it can, in fact, be treated just like the record itself, or any other object. In FPC it must be first de-referenced.

With the Delphi code compiled under Lazarus You will get the following messages :
"Error: Illegal qualifier"
"Hint: may be pointer dereference is missing"
Delphi OBJFPC both
Function GetSomeValue(ARecord: PMyRecord):Integer;
begin
If Assigned(ARecord) then
Result:=ARecord.SomeValue
else
Result:=0;
end;
Function GetSomeValue(ARecord: PMyRecord):Integer;
begin
If Assigned(ARecord) then
Result:=ARecord^.SomeValue
else
Result:=0;
end;
Simply use the OBJFPC way, with ^ :
Result:=ARecord^.SomeValue
Delphi accepts this, too.

Note that the behavior of the compiler with regards to (auto) de-referencing pointers can also be influenced using the AUTODEREF modeswitch.

When accessing chars of an indexed string Property of an object, it must be enclosed in parentheses

With Delphi it is possible to treat a Property exactly like some other const or var, e.g. even up to accessing individual chars of a string directly, while this is not always possible in FPC, specifically for indexed properties. Instead it must be enclosed in parentheses, to make distinct. While this may not always hold true it is probably a good practice to consider anyway. For example

Delphi OBJFPC
Type TSomeComponent=class(TComponent)
//More code...
Published
Property MyString:String index 3 read GetMyString;
//More code...
End;
var
MyChar:char;
begin
If Length(MyString)>2 then
//no parenthesis needed
MyChar:= MyString[3];
//More code...
end;
Type TSomeComponent=class(TComponent)
//More code...
Published
Property MyString:String index 3 read GetMyString;
//More code...
End;
var
MyChar:char;
begin
If Length(MyString)>2 then
//parenthesis sometimes needed
MyChar:= (MyString)[3];
//More code...
end;
You must typecast pointers to actual type when using with var or function of that type

Sometimes in Delphi you will have a null pointer variable representing an object. While it might seem a complex situation, it is oddly quite common especially in large component packs as a method of preventing too many circular includes between objects in different units. In Delphi it is then possible to send this null pointer to a function expecting that object, without bothering to typecast to actual type, in fpc you must typecast.

For example —

Delphi OBJFPC
Unit 1
Type 
TSomeObject=class(TComponent)
//More code...
End;
Procedure DoSomething(Value: TSomeObject);
Function GetSomeObject: TSomeObject;
Unit 2
Type 
TSomeComponent=class(TComponent)
//More code...
Published SomeObject: Pointer;
//More code...
End;
Application
var 
MyComponent: TSomeComponent;
begin
MyComponent.SomeObject:=GetSomeObject;
//More code...
DoSomething(MyComponent.SomeObject);
end;
Unit 1
Type 
TSomeObject=class(TComponent)
//More code...
End;
Procedure DoSomething(Value: TSomeObject);
Function GetSomeObject: TSomeObject;
Unit 2
Type TSomeComponent=class(TComponent)
//More code...
Published SomeObject: Pointer;
//More code...
End;
Application
var 
MyComponent: TSomeComponent;
begin
MyComponent.SomeObject:=Pointer(GetSomeObject);
//More code...
DoSomething(TSomeObject(MyComponent.SomeObject));
end;

Resources

Note-icon.png

Note: The section below may not be necessary. Any recent version of Lazarus directly supports .res files. The Windows Lazarus installer includes a resource compiler which supports .rc files. On *nix, please make sure windres is installed so you can use .rc files. See http://wiki.lazarus.freepascal.org/Lazarus_Resources#FPC_resources

Delphi resource files are win32 specific and not compatible with Lazarus, so you’ll have to recreate and compile them using the lazres tool. Lazres can be found in the lazarus/tools subdirectory. If you’ve downloaded the Lazarus sources, you’ll need to compile it first.

  • cd lazarus/tools
  • make install

To add a resource to your application:

  • lazres myresource.lrs mypix.xpm anotherpix.xpm
  • Add the LResources unit to your Uses clause
  • Include the .lrs file you created under the initialization block

Example:

function TForm1.LoadGlyph(const GlyphName: String): TBitMap;
begin
Result:= TPixmap.Create;
Result.LoadFromLazarusResource(GlyphName);
end;
//More code...
begin
Speedbutton1.glyph:= LoadGlyph('mypix');
//More code...
end;
initialization
{$I unit1.lrs}
{$I myresource.lrs}
end.

Another method to convert a Delphi or Kylix project to Lazarus

  • Rename or copy all .dfm or .xfm files to .lfm (Very old Delphi versions do not produce a text-based .dfm file. The convert utility, if present in the bin folder can be used to covert the .dfm first))
  • Rename or copy .dpr file to .lpr
  • Make all necessary changes to .lpr file:
  1. Add {$mode delphi}{$H+} or {$mode objfpc}{H+} directives
  2. Add ‘Interfaces’ to uses clause
  3. Comment out or delete {$R *.res} or directive if needed
  • Make necessary changes to all .pas unit files:
  1. Add {$mode delphi}{$H+} or {$mode objfpc}{H+} directives
  2. Add ‘LResources’ — to do: check if this is still needed for any vaguely new Lazarus version
  3. If the form has buttons, add ‘Buttons’ to uses clause
  4. Comment out or delete {$R *.dfm} or {$R *.xfm} directive
  5. Add ‘Initialization’ section at the end of each unit file, and add {$I unitname.lrs} directive in it
  • Select Project->New Project from file
  • Select the .lpr file
  • In the ‘Create a new project’ window, choose ‘Application’
  • Build project and make further necessary corrections to get proper compilation. At this point the .lpi file is generated automaticaly. You may get ‘Error reading Form’ messages, click on ‘Continue Loading’ if you do.
  • Save all, and you have a Lazarus project  :-)

Getting Help

If you encounter a problem during conversion that you just can’t solve, there are a wide variety of places to get help.

Documentation

For pure Object Pascal and FPC issues The best place to start is the Free Pascal Documentation by Michaël Van Canneyt and Florian Klämpfl.
For more Lazarus oriented problems The Lazarus Project Documentation in the Lazarus-CCR Knowledgebase Main Page is the next place to look.

Peer support

Mailing lists You can post a question on any of the mailing lists for the Free Pascal Compiler or the FPC/Lazarus forums where a lot of experts are subscribed.
If you have access to IRC: On irc.freenode.net: #fpc for FPC, or #lazarus-ide for Lazarus

Knowledge bases

There are some outstanding search and knowledge bases online that can also be a great help for learning new techniques and solving problems:

  • Tamarack Associates operates a fast search engine specifically for the Borland usenet archives.
  • Mer Systems Inc. provides a similar search engine.
  • Another outstanding source of information along with a sitewide search capability is Earl F. Glynn’s Computer Lab and Reference Library.

Packaging and Releasing your component

Creating a Lazarus package for your component(s)

Creating a package makes installing the code you’ve converted a much easier process… especially if you’re providing more than one component. Mattias Gärtner has written an overview of Lazarus Packages that should be read before beginning this process.

Documentation

The purpose of this site and the wiki format is to make the generation of professional documentation an easy and quick process. The wiki also makes it possible to see the results of your posting immediately and make any changes you’d like in real time.

Using the Lazarus-CCR wiki to create nice looking documentation is very easy. If you’ve never used wiki markup before, you can get familiar with it in the Sand Box practice area.

Creating a Code Release Page

The Code Release Page contains vital information about your component that a potential downloader will need to know, such as license, intended platform, status (alpha, beta, stable…), where to download it, who wrote it, is support available… etc.

The following procedure will let you create a Code Release Page with your browser:

  • Go to the Release new component
  • Type the name of your component in the textbox and click on Create Article
  • Fill in the template and hit save.
  • Edit the Components and Code examples page and add the link to your newly created page to the «Released Components» section. Save the modified page.

Submitting the component

If you’re a release technician on the project, upload your component to the SourceForge File Release System and add it to the list of release packages. Otherwise send it to one of the project administrators (Tom Lisjac or Vincent Snijders) and we’ll add it to the repository. Before we upload it to SourceForge, you have to create a Code Release Page to describe your component. You can use the Release new component page, to start creating such a page.

If you think you need to continue to develop on the component, we can also put it into SVN so you’ll continue to have access to it. If we get tired from committing your patches, we will give you write access to the SVN, so you can commit your patches yourself. For details see Using the Lazarus-ccr SVN repository.

See also

  • Lazarus For Delphi Users
  • Delphi language features missing from the Free Pascal Compiler

Возможно, вам также будет интересно:

  • Illegal devices please use genuine как исправить ошибку подключения
  • Illegal constructor вайлдберриз ошибка
  • Ilife v8s ошибка e41
  • Ilife v80 ошибка e41
  • Igdusc64 dll ошибка ведьмак 3

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии