views:

73

answers:

2

Hello,
I just started using FPC to pratice more my old knowleadge of Pascal, but now for Linux, then I started seeing much this comment after the 'program' declaration:

{$apptype console}

But is this a best pratice comment or a type of declaration? Thanks.

+2  A: 

{$ ...} are not just comments but they are compiler directives.

Here is a list of compiler directives.

Specifically, {$apptype console} tells the compiler to make a console instead of a gui application.

Nick D
{$apptype console} can also be useful to add a console in a GUI application. For example for DUnit / FPCUnit tests if you need some log messages to be displayed while the tests are running.
mjustin
+1  A: 

Yes, but contrary to Delphi, in FPC console is default. Delphi has GUI default (*)

Because the defaults vary between Delphi and FPC, it is a reasonable practice to add it, if there is a chance the code must run under Delphi.

(*) strictly speaking not, since the console app flag can also be set using the cmdline. But while thus not 100% mandatory, it is smart to add it in 99.9% of the cases in Delphi.

Marco van de Voort