Recent

Author Topic: default mode  (Read 1366 times)

Paolo

  • Hero Member
  • *****
  • Posts: 538
default mode
« on: March 02, 2024, 06:54:56 pm »
hello,

I noticed that some simple units of mine ported from Delphi do not have any "mode" directive.
question: when no {$mode xxx} is specified which is the default one ?

thank you.
« Last Edit: March 02, 2024, 11:30:23 pm by Paolo »

cdbc

  • Hero Member
  • *****
  • Posts: 1673
    • http://www.cdbc.dk
Re: default mode
« Reply #1 on: March 02, 2024, 07:01:28 pm »
Hi
That would be {$mode fpc}
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

rvk

  • Hero Member
  • *****
  • Posts: 6592
Re: default mode
« Reply #2 on: March 02, 2024, 07:08:14 pm »
Unless you are using Lazarus.
Then it would be ObjFPC ;)
https://wiki.freepascal.org/Mode_ObjFPC

Paolo

  • Hero Member
  • *****
  • Posts: 538
Re: default mode
« Reply #3 on: March 02, 2024, 08:03:53 pm »
Thanks both, I am on lazarus, thus objfpc
« Last Edit: March 02, 2024, 11:30:33 pm by Paolo »

rvk

  • Hero Member
  • *****
  • Posts: 6592
Re: default mode
« Reply #4 on: March 02, 2024, 08:08:24 pm »
Do note that only {$mode objfpc} is the default in Lazarus.
But also shortstring is default (for objfpc).
So {$mode objfpc}{$h-} is the complete default.

That's why you see almost always see {$mode objfpc}{$h+} at the top of the source.

For {$mode delphi} {$h+} isn't needed because h+ is the default in delphi-mode.

tetrastes

  • Hero Member
  • *****
  • Posts: 600
Re: default mode
« Reply #5 on: March 02, 2024, 09:38:38 pm »
No, in Lazarus the default is {$H+}. These are the default options in Lazarus:

rvk

  • Hero Member
  • *****
  • Posts: 6592
Re: default mode
« Reply #6 on: March 02, 2024, 09:42:16 pm »
No, in Lazarus the default is {$H+}. These are the default options in Lazarus:
Ha, ok. What happens if you add only {$mode objfpc} at the top of the source code?
Will it revert back to {$h-} or will it keep {$h+}.

(Although I would always advice to add the mode and H at the top just to be sure 😊)

Paolo

  • Hero Member
  • *****
  • Posts: 538
Re: default mode
« Reply #7 on: March 02, 2024, 11:29:52 pm »
I usully work with {$Mode Delphi}

thanks again

PascalDragon

  • Hero Member
  • *****
  • Posts: 5764
  • Compiler Developer
Re: default mode
« Reply #8 on: March 04, 2024, 08:55:21 pm »
No, in Lazarus the default is {$H+}. These are the default options in Lazarus:
Ha, ok. What happens if you add only {$mode objfpc} at the top of the source code?
Will it revert back to {$h-} or will it keep {$h+}.

A $MODE-directive will change $H to the corresponding default state of that mode.

 

TinyPortal © 2005-2018