开发者

Is $apptype a Best Practice Comment?

开发者 https://www.devze.com 2022-12-12 14:41 出处:网络
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开发者_如何学JAVA\' declaration:

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开发者_如何学JAVA' declaration:

{$apptype console}

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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消