Please note that I'm not saying that the behavior is good, I'm just saying how it is (and it would probably not be easy to solve either).
I'm relieved you're not saying it's good. Solving the problem isn't hard, it simply shouldn't accept "ProcedureName" as a type name. Delphi doesn't accept it, therefore, if FPC didn't accept it either, it would not affect Delphi compatibility.
Solving the problem is not as easy as you think.
Change the type from HWND to TRECORD_TYPE_C and things don't work the same way anymore.
The compiler complains about the record not being fully defined, because the record type that is currently declared
must be in scope to allow constructs like this:
type
TMyRecord = record
f: ^TMyRecord;
end;
A pointer to the record can be used, but the non-pointer type is not allowed (except for method declarations when modeswitch
AdvancedRecords is enabled, because they don't need the size of the record, yet).
Not really directly related to the topic but, combine the above with the ability of redefining standard types (such as integer) and some rather "interesting" results can be had. Same applies to the presence of TRECORD_TYPE_A and TRECORD_TYPE_B (I simply couldn't resist.)
First of
Integer is not a built in type, it's just an alias for
SmallInt in unit
System or
LongInt in unit
ObjPas (if modes
Delphi,
ObjFPC or
MacPas are used). Second you can use builtin types without any problems, because they are in fact namespaced to the
System unit. Thus you can declare a type
LongInt = Boolean, but continue to use the builtin type using
System.LongInt. The compiler even allows you to redefine some apparent keywords like
Break or
Continue (and yes, that was a fun debug session when I discovered that back when I still used Delphi 6

).
Talking about "result"(s), why does FPC complain about "result" in the function ?... Delphi has no problem with it and, I don't see why FPC would.
The default mode of FPC is mode
FPC which is essentially a mode
TP with some extensions (like overloading). Use of the
Result variable is only enabled in the "modern" modes like
Delphi or
ObjFPC or if modeswitch
Result is used.