teststufff.pas:
unit teststufff;
interface
procedure teststufff;
implementation
procedure teststufff;
begin
end;
end.
fpc teststufff.pas:
Free Pascal Compiler version 3.2.2 [2021/07/09] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling teststufff.pas
13 lines compiled, 0.0 sec
teststuffv.pas:
unit teststuffv;
interface
var teststuffv: integer;
implementation
end.
fpc teststuffv.pas:
Free Pascal Compiler version 3.2.2 [2021/07/09] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling teststuffv.pas
teststuffv.pas(5,15) Error: Duplicate identifier "teststuffv"
teststuffv.pas(7,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode
Why does the name of a variable collide with the unit's name? If it is because of
"identifier", then why does not the function's name colliding with it? I do not understand the logic.
Also, how can i prevent/avoid this collision? The names have to remain the same.