Recent

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

simone

  • Sr. Member
  • ****
  • Posts: 255
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.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7506
Re: Predefined constant for GUI applications
« Reply #1 on: March 11, 2019, 09:04:11 pm »
{$ifndef console}

simone

  • Sr. Member
  • ****
  • Posts: 255
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


Thausand

  • Full Member
  • ***
  • Posts: 234
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: 674
  • 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.