As discussed in this thread, there are a number of places where Oxygene is not compatible with FPC, at least as of Elements 10. These changes would go a long way toward allowing shared code between FPC and Oxygene targets.
Conditional directive within a definition.
aBool,
{$IF NOT OXYGENE}
aBoolTwo,
{$ENDIF NOT OXYGENE}
aBoolThree: Boolean;
Conditional directive within a case statement.
CASE dataType OF
kDefault:
BEGIN
...
END;
{$IF Target_Android}
kAndroidStuff:
BEGIN
...
END;
{$ENDIF}
END;
otherwise keyword in case statements (already logged as bug #81607)
Support for destructor keyword (not recognized even in Delphi compatibility mode). It would be nice to have a compatibility option at least to treat ādestructorā as an alternative for āprocedureā even though Oxygene doesnāt actually use destructors.
Return function value by assigning to function name.
function IsActive: boolean;
begin
IsActive := false;
end;
The compiler complains about not recognizing the {$ALIGN} directive. It seems like this should simply be ignored instead of throwing an error - again, at least in compatibility mode.
Hmm Iām not seeing it on .2364. Created a new java console app, set Delphi Compatibility to āYesā in settings, added a case statement in main like this:
class method Main(args: array of String): Int32;
begin
var i: LongInt;
i := 3;
case i of
1:
System.out.println('1');
2:
System.out.println('2');
otherwise:
System.out.println('other');
end;
end;
I get build error Type mismatch, expected "Integer" on the āotherwiseā.
Hmm, reproduced. will reopen. [ā¦] ah my bad, looks like we had a commit for it, nit the issue isnāt closed yet. Iāll follow up with the compiler team.
Side Q: does otherwise need the : or nor? else does NOT use a colon, and I had assumed otherwise was supposed to work interchangeably with else, in case?
Hmm Iāll have to play around with the first one to see what was causing the problem - it is working fine for me too. I actually noticed the problem in Waterās code complete, not EBuild. I have the legacy preprocessor enabled in my project, so the compiler doesnāt complain about these, but Water still appears to use the Elements 10 preprocessor for code complete. That said, this is the same problem I was originally having with the compiler before enabling legacy preprocessor. Iāll try to see if I can figure out whatās actually causing a problem with this.
Variable definitions, as in the specific case I mentioned here. I can wrap entire method definitions in a directive without issue. I can also wrap a variable definition without issue, I just canāt wrap in the middle of a variable definition as in the example above.
Another compatibility issue is the original one from this thread that it seems we all forgot about by the end of the thread (myself included)
{$if TARGET_RT_BIG_ENDIAN}
type
wide = record
case boolean of
false:
(hi: SInt32;
lo: UInt32);
true:
(int: SInt64)
end;
{$endif}
It seems that case statements are not allowed in records, even in a false ifdef. I understand it must be syntactically correct throughout, but it would be fantastic for compatibility to at least allow FPC-correct syntax in undefined blocks as Marc mentioned in that thread.
@ck Actually I just noticed, destructor still does not seem to be supported, at least by the Water IDE. The changelog for .2365 shows 81783: Delphi/FPC Compatibility: support for destructor (wip)
When I compile with DESTRUCTOR Destroy; in Water it shows error colon (:) expected.