Forum > General

difference between {$MODE Delphi} and {$mode objfpc}{$H+}

(1/1)

epergola:
What is it?
I used Lazarus Tools to convert many Forms from Delphi to Lazarus.
They have {$MODE Delphi} added to them by Lazarus.
I created some new forms, and they have {$mode objfpc}{$H+}
What is the difference between the 2? Is there any difference in behaviour in compiling or executing?

clauslack:
Look at this

http://www.freepascal.org/docs-html/prog/progap4.html#progse62.html

Kornelius:
I tried to compare and found the following for D =  {$MODE Delphi} and O =  {$mode objfpc}

O: The Objpas unit is loaded right after the system unit. One of the consequences of this is that the type Integer is redefined as Longint.
D: The Objpas unit is loaded right after the system unit. One of the consequences of this is that the type Integer is redefined as Longint. Inversely, it means that system.integer is always 16-bit.

O: You must use the address operator to assign procedural variables.
D: you cannot use the address operator to assign procedural variables.

O: A forward declaration must be repeated exactly the same by the implementation of a function/procedure. In particular, you cannot omit the parameters when implementing the function or procedure, and the calling convention must be repeated as well.
D: A forward declaration does not have to be repeated exactly the same by the implementation of a function/procedure. In particular, you can omit the parameters when implementing the function or procedure.

O: Overloading of functions is allowed.
D: Overloading of functions only allowed with Overload modifier.

O: Parameters in class methods cannot have the same names as class properties.
D: Parameters in class methods can have the same names as class properties (although it is bad programming practice).

O: Nested comments are allowed.
D: Nested comments are not allowed.

and furthermore:

O: Exceptions, classes and Interfaces are enabled.
O: You can use the cvar type.
O: PChars are converted to strings automatically.
O: Strings are shortstrings by default. You can use the -Sh command line switch or the {$H+} switch to change this.

D: Ansistrings are default, this means that $MODE DELPHI implies an implicit {$H ON}.
D: Inline code is allowed: There is no need to enable it with the {$INLINE} directive.

marcov:
Quite a nice write up. Missing generics though, which are some of  biggest differences.

Also, iirc default assembler mode is set to Intel with mode delphi, but haven't tested/relied on that for years.

Navigation

[0] Message Index

Go to full version