Cannot redefine LongInt
Original Reporter info from Mantis: harleyflanders
-
Reporter name: Prof. Harley Flanders
Original Reporter info from Mantis: harleyflanders
- Reporter name: Prof. Harley Flanders
Description:
As I understand pascal, and identifier can be redefined.
The following code fails to compile with Lazarus. It compiles with Delphi.
Please note error messages, included as comments.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs;
type
TForm1 = class(TForm)
private
{ private declarations }
public
{ public declarations }
end;
LongInt = array of Integer;
var
Form1: TForm1;
function Equal(const A, B: LongInt): Boolean; overload;
function Equal(const A: LongInt; const N: Integer): Boolean; overload;
implementation
function Equal(const A, B: LongInt): Boolean; overload;
var K: Integer;
begin
Result := (Length(A) = Length(B));
if not Result then Exit;
for K := 0 to Length(A) - 1 do
begin
Result := (A[K] = B[K]);
if not Result then Break;
end;
end;
function Equal(const A: LongInt; const N: Integer): Boolean; overload;
begin
Result := (Length(A) = 1) and (A[0] = N);
end;
(* Compiler Error Mesasages
Unit1.pas(18,13) Hint: Type "LongInt" redefinition
Unit1.pas(40,3) Error: Asm: Duplicate label UNIT1_EQUALLONGINT
LONGINT$$BOOLEAN
Unit1.pas(52,1) Fatal: There were 1 errors compiling module, stopping
*)
initialization
{$I Unit1.lrs}
end.
Mantis conversion info:
- Mantis ID: 9591
- Version: 2.0.4
- Monitored by: » Artem3213212 (Artem3213212)