Sign in Join
Wiki copytemporary

Mode ObjFPC: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Mode ObjFPC

OldNewLine
1+The mode **ObjFPC**, switched on with `{$mode objfpc}` in [[Source code|source code]], or `-Mobjfpc` on the [[Command-line interface|command line]], is the default mode for [[Lazarus]] source files (the default [[Compiler Mode|compiler mode]] when not using Lazarus is [[Mode FPC|FPC mode]]).
2+
3+Using the ObjFPC mode has the following consequences:
4+
5+1. The [[@|address operator]] has to be used to assign procedural variables. Use `{$modeswitch classicProcVars+}` to disable this requirement.
6+2. A [[Forward|forward declaration]] must be repeated exactly the same by the [[Implementation|implementation]] of a [[Function|function]]/[[Procedure|procedure]]. In particular, parameters cannot be omitted when implementing the function or procedure, and the calling convention must be repeated as well.
7+3. [[Overload|Overloading]] of functions is allowed.
8+4. Nested [[Comments|comments]] are allowed.
9+5. The [[Objpas]] unit is loaded right after the system unit. One of the consequences of this is that the [[Integer|type integer]] is redefined as [[Longint|longint]].
10+6. The [[Cvar|cvar]] type may be used.
11+7. [[PChar|PChars]] are converted to [[String|strings]] automatically.
12+8. Parameters in class methods cannot have the same names as class properties.
13+9. Strings are [[Shortstring|shortstrings]] by default. This may be changed by using the `-Sh` command line switch or the `{$H+}` switch.
14+10. [[Exceptions]], [[Class|classes]] and [[Interfaces]] are enabled.
15+11. Inline code is allowed: There is no need to enable it with the `{$INLINE}` directive.
16+
17+---
18+*From the Free Pascal wiki, page "Mode ObjFPC", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history