Recent

Author Topic: Predefined constant for GUI applications  (Read 1758 times)

simone

  • Hero Member
  • *****
  • Posts: 573
Predefined constant for GUI applications
« on: March 11, 2019, 08:57:59 pm »
In order to conditionally compile some piece of code with FPC, is there a predefined constant that lets to discriminate if the source is a GUI program, i.e. is compiled with -WG option? Thanks in advance.
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: Predefined constant for GUI applications
« Reply #1 on: March 11, 2019, 09:04:11 pm »
{$ifndef console}

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Predefined constant for GUI applications
« Reply #2 on: March 11, 2019, 10:16:33 pm »
Very simple! I did not know this symbol because is not present on the official list:

https://www.freepascal.org/docs-html/current/prog/progap7.html#x333-349000G

Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Thausand

  • Sr. Member
  • ****
  • Posts: 292
Re: Predefined constant for GUI applications
« Reply #3 on: March 12, 2019, 06:59:13 am »
hello,

You write not official list is console but is written in other part here https://www.freepascal.org/docs-html/prog/progse3.html#progsu86.html

It writes "Global directives" and for console you watch part AppType here https://www.freepascal.org/docs-html/prog/progsu86.html#x94-930001.3.3

There it writes "console" and more.

so is official  :D

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: Predefined constant for GUI applications
« Reply #4 on: March 12, 2019, 09:01:59 am »
{$ifndef console}
Please note that this will only work in the main project file or if all units are recompiled.

 

TinyPortal © 2005-2018