Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Apart from what lassevk said, you can also use a few other methods of compiler-evaluation (since Delphi 6, I believe) :</p> <pre><code>{$IF NOT DECLARED(SOME_SYMBOL)} // Mind you : The NOT above is optional {$ELSE} {$IFEND} </code></pre> <p>To check if the compiler has this feature, use :</p> <pre><code> {$IFDEF CONDITIONALEXPRESSIONS} </code></pre> <p>There are several uses for this.</p> <p>For example, you could check the version of the RTL; From the Delphi help :</p> <blockquote> <p>You can use RTLVersion in $IF expressions to test the runtime library version level independently of the compiler version level.<br> Example: {$IF RTLVersion >= 16.2} ... {$IFEND}</p> </blockquote> <p>Also, the compiler version itself can be checked, again from the code:</p> <blockquote> <p>CompilerVersion is assigned a value by the compiler when the system unit is compiled. It indicates the revision level of the compiler features / language syntax, which may advance independently of the RTLVersion. CompilerVersion can be tested in $IF expressions and should be used instead of testing for the VERxxx conditional define. Always test for greater than or less than a known revision level. It's a bad idea to test for a specific revision level.</p> </blockquote> <p>Another thing I do regularly, is define a symbol when it's not defined yet (nice for forward-compatiblity), like this :</p> <pre><code> {$IF NOT DECLARED(UTF8String)} type UTF8String = type AnsiString; {$IFEND} </code></pre> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload