Tutorial :Is $apptype a Best Practice Comment?



Question:

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

{$apptype console}  

But is this a best practice comment or a type of declaration?


Solution:1

{$ ...} 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.


Solution:2

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »