Conditional code for FPC modes

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Conditional code for FPC modes

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Conditional code for FPC modes

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Conditional code for FPC modes

Sven Barth-2
In reply to this post by Juha Manninen

Am 15.06.2016 10:15 schrieb "Juha Manninen" <[hidden email]>:
>
> 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.

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Conditional code for FPC modes

Mattias Gaertner
On Wed, 15 Jun 2016 11:18:38 +0200
Sven Barth <[hidden email]> wrote:

> Am 15.06.2016 10:15 schrieb "Juha Manninen" <[hidden email]>:
> >
> > 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Conditional code for FPC modes

Mattias Gaertner
On Wed, 15 Jun 2016 11:43:59 +0200
Mattias Gaertner <[hidden email]> wrote:

>[...]
> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Conditional code for FPC modes

Jonas Maebe-2
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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal