Re: Compiler directives



Abdullah Kauchali wrote:

> Should they be avoided? Why?

I think some are very useful:

{$M+} I have had to use this in the past when I needed to generate RTTI
information but did not want to derive from TPersistent.

{$IFDEF}, {$DEFINE} etc. : Important if you're building commercial
components or libraries that support different Delphi versions. Sort of
Important if you might want a copy of code that is specific to one
customer (when you sell to many) but there usually are other ways to do
this, including code forking which is perhaps the easiest business
solution.

{$APPTYPE CONSOLE} I think the compiler needs this to emit some
information in the EXE.

{$ASSERTIONS ON} Use it for developer level error catching. Tricky if
somebody puts run-time condition checks in there, but that's a training
thing.

{$DENYPACKAGEUNIT}{$DESIGNONLY} etc. are package level compiler
instructions

{$I+} Have had to use this when using type "Text" and
OpenFile/Reset/Rewrite functions.

There are others that one tends to use because they are debug options,
optimization and so on.

{$I} Well this is only useful in some cases, and I think the difference
between doing this vs. using the unit initialization and finalization
sections don't run. But, is useful for IFDEF sets.

I've never had to use:
{$Align}, {$Stackchecks}, {$M}, {$R}, {$REALCOMPATIBILITY}, {$U} or
{$Y}

I think are dangerous to use at all:
{$BoolEval On} {$Warnings Off}


--
Deepak Shenoy (TeamB)
http://shenoyatwork.blogspot.com
.