Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.168 Beiträge
 
Delphi 12 Athens
 
#4

Re: TMS Unicode Components und RAD2009

  Alt 23. Jun 2009, 09:23
Diese ja, aber es gibt notfalls auch noch eine Konstante

die Konstante könnte man nun per Compilerdirektive abfragen, oder auch dirtekt im Code verwenden und sie ist virtuell in der System-Unit definiert:
Delphi-Quellcode:
{$IFDEF CONDITIONALEXPRESSIONS}
  {$IF CompilerVersion >= 20.0} {$DEFINE Delphi2009plus} {$IFEND}
{$ENDIF}

IF CompilerVersion >= 20 Then ...
da gibt es auch eine Constante für die verwendete RTL
und ich hab grad die Lizenz gefunden
Delphi-Quellcode:
unit System;

...

interface

(* You can use RTLVersion in $IF expressions to test the runtime library
  version level independently of the compiler version level.
  Example:  {$IF RTLVersion >= 16.2} ... {$IFEND}                  *)


const
  RTLVersion = 20.00;

{$EXTERNALSYM CompilerVersion}

(*
const
  CompilerVersion = 0.0;

  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.
*)


{$IFDEF DECLARE_GPL}
(* The existence of the GPL symbol indicates that the System unit
  and the rest of the Delphi runtime library were compiled for use
  and distribution under the terms of the GNU General Public License (GPL).
  Under the terms of the GPL, all applications compiled with the
  GPL version of the Delphi runtime library must also be distributed
  under the terms of the GPL.
  For more information about the GNU GPL, see
  [url]http://www.gnu.org/copyleft/gpl.html[/url]

  The GPL symbol does not exist in the Delphi runtime library
  purchased for commercial/proprietary software development.

  If your source code needs to know which licensing model it is being
  compiled into, you can use {$IF DECLARED(GPL)}...{$IFEND} to
  test for the existence of the GPL symbol.  The value of the
  symbol itself is not significant.   *)


const
  GPL = True;
{$ENDIF}

PS: falls du dich nicht auf die Versionsnummer stützen willst, dann kannst du auch andere Merkmale abfragen, denn ab der nächsten Delphiversion müßtest du deine Versionsabfrage wieder anpassen (abgesehn vorm vorherigen Beispiel, aber VER200 wird da nicht mehr definiert sein)
denn:
siehe Code weiter oben
It's a bad idea to test for a specific revision level.


Delphi-Quellcode:
{$UNDEF UseUnicode}
{$IFDEF CONDITIONALEXPRESSIONS}
  {$IF SizeOf(Char)=2} {$DEFINE UseUnicode} {$IFEND}
{$ENDIF}
oder falls man nur wissen möchte, ob ein gestimmter Datentyp vorhanden ist
Delphi-Quellcode:
{$UNDEF SupportUnicode}
{$IFDEF CONDITIONALEXPRESSIONS}
  {$IF Declared(UnicodeString)} {$DEFINE SupportUnicode} {$IFEND}
{$ENDIF}

hatte so bis vor knapp 1,5 Jahren immer soeine Datei verwendet (sowas gibt es auch in den JEDIs),
aber inzwischen stütze ich mich oftmals nur noch direkt auf Feature-Checking und spar mir das Dazulegen einer weiteren Datei, vorallem wenn es mir in dem Code nur um ein/zwei Dinge geht.


PS:
{$IFDEF CONDITIONALEXPRESSIONS} ist in "neueren" mindestens seit Delphi 6 (weiß es nicht genau) nicht mehr nötig, da diese das {$IF } kennen.
Angehängte Dateien
Dateityp: txt fversionscheck.inc_116.txt (53,3 KB, 4x aufgerufen)
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat