Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-06

Conditional code for FPC modes

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

Are there defines matching the modes in FPC, for example {$mode delphiunicode} ? I want to do something like :

  {$IFDEF delphiunicode}
    ...
  {$ELSE}
    ...
  {$ENDIF}

Juha

Reply by email

Juha Manninen
to Juha Manninen

More accurately, I want to check {$ModeSwitch UnicodeStrings}. Anyway, if there is no define, I can use:

  {$IF SizeOf(Char) = 2}

Works well although the highlighter in Lazarus editor shows it wrong.

Juha

Reply by email

Sven Barth
to Juha Manninen: Are there defines matching the modes in FPC, for example {$mode delphiunicode} ? I want…
"Juha Manninen" wrote
Are there defines matching the modes in FPC, for example {$mode

delphiunicode} ?

Show quoted text 6 lines
I want to do something like : {$IFDEF delphiunicode} ... {$ELSE} ... {$ENDIF}

There are. They are FPC_<modename>, though DelphiUnicode seems to be missing. You shouldn't directly check for that anyway, but instead for FPC_UNICODESTRINGS which is set if String = UnicodeString independently of the mode.

Regards,
Sven

Reply by email

Mattias Gaertner
to Sven Barth
Show quoted text 15 lines
Am 15.06.2016 10:15 schrieb "Juha Manninen" : > > Are there defines matching the modes in FPC, for example {$mode delphiunicode} ? > I want to do something like : > {$IFDEF delphiunicode} > ... > {$ELSE} > ... > {$ENDIF} There are. They are FPC_<modename>, though DelphiUnicode seems to be missing. You shouldn't directly check for that anyway, but instead for FPC_UNICODESTRINGS which is set if String = UnicodeString independently of the mode.

Thanks for the hint. Done.

Mattias

Reply by email

Mattias Gaertner
to Mattias Gaertner
[...] Thanks for the hint. Done.

Oops. Wrong thread.

To my rescue a hint:
You can see the actual FPC defines in Lazarus by placing the cursor in the directive and pressing Ctrl+Space:

{$IFDEF FPC|}

I spotted several hidden gems via the list of FPC* macros.

Mattias

Reply by email

Jonas Maebe
to Mattias Gaertner
Mattias Gaertner wrote
I spotted several hidden gems via the list of FPC* macros.

Note that a bunch of these are probably temporary ones, search for "Temporary" in compiler/options.pas for a list of those in your current FPC version. Those are removed from time to time as they are no longer required for bootstrapping.

Jonas

Reply by email