Difference between revisions of "Mode ObjFPC"

From Lazarus wiki
Jump to navigationJump to search
m (fix typo)
(-Mobjfpc)
Line 1: Line 1:
 
{{Mode_ObjFPC}}
 
{{Mode_ObjFPC}}
  
The mode '''ObjFPC''', switched on with '''{$mode objfpc}''', is the default mode for [[Lazarus]] source files.
+
The mode '''ObjFPC''', switched on with '''{$mode objfpc}''' in source code, or '''-Mobjfpc''' on the command line , is the default mode for [[Lazarus]] source files (the default compiler mode when not using Lazarus is [[Mode_FPC|FPC]]).
  
 
Using the ObjFPC mode has the following consequences:
 
Using the ObjFPC mode has the following consequences:

Revision as of 00:35, 12 September 2017

English (en) español (es) français (fr)

The mode ObjFPC, switched on with {$mode objfpc} in source code, or -Mobjfpc on the command line , is the default mode for Lazarus source files (the default compiler mode when not using Lazarus is FPC).

Using the ObjFPC mode has the following consequences:

  1. The address operator has to be used to assign procedural variables.
  2. A forward declaration must be repeated exactly the same by the Implementation of a function/procedure. In particular, the parameters cannot be omitted when implementing the function or procedure, and the calling convention must be repeated as well.
  3. Overloading of functions is allowed.
  4. Nested comments are allowed.
  5. 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.
  6. The cvar type may be used.
  7. PChars are converted to strings automatically.
  8. Parameters in class methods cannot have the same names as class properties.
  9. Strings are Shortstrings by default. This may be changed by using the -Sh command line switch or the {$H+} switch.
  10. Exceptions, Classes and Interfaces are enabled.