Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Delphi программирование > Общие вопросы Delphi
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 21.10.2016, 11:37   #1
7in
(aka Jin X) !RTFM!
Форумчанин
 
Аватар для 7in
 
Регистрация: 14.12.2014
Сообщений: 295
Хорошо DEFINE'ы для разных версий Delphi (пользуйтесь!)

Сделал большой include-файл с define'ами, определяемыми в зависимости от версии Delphi.
Информация собрана из различных источников, часть их них перепроверены и откорректированы.

Зачем это нужно? Например, вы пишете прогу или модуль, которые, во-первых, должны компилиться на разных версиях Delphi, во-вторых, использовать новые возможности.

Привожу описание (сам код см. в архиве):
Код:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// *** THIS INCLUDE IS DESIGNED FOR DELPHI COMPILERS VERSION 6 AND ABOVE !!! \\\ It outputs "__YOU_NEED_AT_LEAST_DELPHI_6_OR_ABOVE_TO_COMPILE_THIS__" error line to code for earler compiler versions! //
// *** This include cannot be used with Delphi 8 and 2007 for .NET compilers and will show fatal message in these cases !!!                                                                            //
// *** It's recommended to include this file right after "program" or "interface" keywords and other $DEFINE's declarations.                                                                           //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ===============
// CHANGES HISTORY
// ===============
// v1.00 beta (04.10.2016)
// [!] The first version of the include :)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This include defines symbols "IsDelphiXXX" and "DelphiXXX" where XXX is 6, 7, 2005, 2006, 2007, 2009, 2010, XE (and XE1), XE2..XE8, Seattle (and 10), Berlin (and 101).
// Symbol "IsDelphiXXX" is defined for exact version, "DelphiXXX" for specified and all above versions (e.g. "IsDelphi7" defined only for Delphi 7, "Delphi7" defined for Delphi 7 and above).
// Sumbols "NoDelphiXXX" means using earler version of compiler (you can also check it for incompatibility of exact compiler version). Equals to {$IFNDEF DelphiXXX}.
// Symbols "MOBILE" and "DESKTOP" are defined for mobile and desktop compilers. Symbols "IOS32" and "IOS64" are defined for 32 and 64-bit iOS platforms.
// Symbol "ANSI" is defined if "UNICODE" symbol is not defined.
// The following symbols are defined to indicate features (directives, attributes, types, etc.) support (see defines below for comments):
// * DelphiBerlin/Delphi101: Android601, UnsafeForAll, VolForAll (and VolatileForAll), WeakForAll, (and also UnsafeVolWeakForAll), MobUtf8String, MobRawByteString, Extended16 (for OS X only),
//     HelpNoPvtAcc (and HelpersNoPrivateAccess);
// * DelphiSeattle/Delphi10: Android511, iOS84;
// * DelphiXE8: FixedIntTypes, DblSizeLongTypes (for 64-bit iOS only), UnitScopedFQN (and UnitScopedFullyQualNames);
// * DelphiXE7: NewDynArrayOps, ParallelLib, NewCompIntr (and NewCompilerIntrin);
// * DelphiXE6: NewMobHPPEMIT;
// * DelphiXE5: ClassOpOverl (and ClassOperatorOverload - both for NextGen compiler);
// * DelphiXE4: Volatile, Weak, Ref, NoOldStrings (for iOS only), ARCModel, ZeroBasedStrings, ExtCompat (and ExtendedCompatibility);
// * DelphiXE3: RecHelpers, AtomicIntrin;
// * DelphiXE2: UnitScopeNames, CrossPlatformRTL, PackedByteAlign, Extended8 (for Win64 only);
// * DelphiXE/DelphiXE1: Align16, CodeAlign, StrongLinkTypes, RegExp, IngoreStringChecks;
// * Delphi2010: EnhancedRTTI, Attributes, Delayed, ClassConstr, ExtraInterfaceOps;
// * Delphi2009: DefaultIntrin, Generics, SmartPointers, AnonymMethods, NestedExcepts, PointerMath, ExitParam, TMonitor, DeprecatedText;
// * Delphi2007: [no symbols];
// * Delphi2006: RecMethods, OpOverl (and OperatorOverload), ClassVars, FastMM;
// * Delphi2005: ForIn, Inline, DynArrayInit, NestedTypes, NestedConst, ClassProperty, Unsafe, UnicodeIds, UsesWildcards, Region, ClassHelpers, Static, Strict, Sealed, Final,
//     AbsClass (and AbstractClasses), Experimental, ArrPropOverl (and ArrayPropertyOverload), MethodInfo;
// * Delphi7: WarnUnsafeCode, TFmtSetOverl (and TFormatSettingsOverloads).
// * Delphi6 and below: [no symbols].
// If some symbol is not defined "NoXXX" symbol is defined (NoForIn, NoInline, NoStatic, NoClassHelpers etc., except build-in but including NoMOBILE, NoDESKTOP, NoIOS32, NoIOS64, NoANSI, NoUNICODE).
// So you can use these symbols with $IFNDEF even if this file may be not included and you prefer to use some feature (e.g. {$IFNDEF NoInline}inline;{$ENDIF} instead of {$IFDEF Inline}inline;{$ENDIF}).
// p.s. "NoOldStrings" symbol is inverted to "OldStrings". Be careful to use {$IFDEF OldStrings} if this include file may be absent because this define will be absent too.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// You may define one or more symbols "NeedDelphiXXX", "OnlyDelphiXXX" or "NotAboveDelphiXXX", "NotForDelphiXXX", "TestWarnings", "TesedDelphiXXX" and "DesignedForDelphiXXX" BEFORE including this file:
// * "NeedDelphiXXX" is used to prevent compilation by earler Delphi version (compiler will show fatal message); you shouldn't use "NeedDelphi6" because this include works only with Delphi 6 and above.
// * "OnlyDelphiXXX" is used to indicate that code can be compiled ONLY by Delphi version you need (compiler will show fatal message for other compiler versions);
// * "NotAboveDelphiXXX" is used to prevent compilation by later Delphi version (compiler will show fatal message);
// * "NotForDelphiXXX" is used to indicate incompatibility with some Delphi version (compiler will show fatal message for this compiler version);
// * "TestWarnings" with one or more "TestedDelphiXXX" are used to show warning messages for Delphi version compilers that are not well-tested with this code;
// * "DesignedForDelphiXXX" is used to indicate compiler version this code is best designed for (compiler will show warning messages for other versions);
//    you may define also "TestedDelphiXXX" symbols (without "TestWarnings") to soften this warning message to hint.
// You may also define one of the following symbols: NeedMobile, NeedDesktop, NeedMSWindows (or NeedWindows), NeedWin32, NeedWin64, NeedMacOS, NeedMacOS32, NeedMacOS64, NeedIOS, NeedIOS32, NeedIOS64,
// NeedAndroid, NeedLinux, NeedLinux32, NeedPosix, NeedPosix32, NeedCPU32bits (or NeedCPU32), NeedCPU64bits (or NeedCPU64), NeedCPU386, NeedCPUx86, NeedCPUx64, NeedCPUARM, NeedCPUARM32, NeedCPUARM64,
// NeedAssembler, NeedUnicode (or NeedUnicodeStrings), NeedAnsi (or NeedAnsiStrings), NeedOldStrings, NeedNextGen to show fatal message if such feature is not supported.
// You may replace "Need" prefix by "Recommend" (e.g. "RecommendAnsi") to show recommendation warning message (instead of fatal message) if such feature is not supported.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// p.s. Information is collected from http://docwiki.embarcadero.com/ and https://stackoverflow.com/questions/...troduced-depre //
// Additional information is collected from http://www.interface.ru/home.asp?artId=6763, http://citforum.ru/programming/delphi/delphi2005 and other (marked as "info from another Internet resource"). //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Вложения
Тип файла: zip DelphiVerDef7x.zip (11.9 Кб, 10 просмотров)
Делаю лабы на Asm/Delphi/C++/Python/VBA(Excel): asmlabs.ru
7in вне форума Ответить с цитированием
Старый 21.10.2016, 11:37   #2
7in
(aka Jin X) !RTFM!
Форумчанин
 
Аватар для 7in
 
Регистрация: 14.12.2014
Сообщений: 295
По умолчанию

Собственно, example'ы (немного утрированные) также представлены в архиве.

Один из примеров использования:
Код:
program DelphiVerExample2;
{$APPTYPE CONSOLE}
// This is a second example of "DelphiVerDef7x.inc" include using.

{$DEFINE NeedDelphi7}  // You need at least Delphi 7 compiler version,
{$DEFINE NeedWindows}  // This code can be compiled only for Windows.
{$I DelphiVerDef7x.inc}
{$IFNDEF DelphiVerDef7x100}{$MESSAGE FATAL 'DelphiVerDef7x.inc file is not included or incompatible version !!!'}{$ENDIF}

{$IFDEF UnitScopeNames}
uses System.SysUtils;
{$ELSE}
uses SysUtils;
{$ENDIF}

procedure WriteRes(const S: String); {$IFDEF Inline}inline;{$ENDIF}
begin
  WriteLn('You''ve entered ' + S)
end;  // AddN

var
  S: String;
  N: Extended;
  D: TDateTime;
{$IFDEF ForIn}
  Ch: Char;
  Ok: Boolean;
{$ENDIF}
begin
  Write('Enter number, date/time or some string: ');
  ReadLn(S);

{$IFDEF ForIn}
  Ok := False;
  for Ch in '., ' do
  begin
    Ok := TryStrToFloat(S, N);
    if Ok then Break;
    {$IFDEF DelphiXE}FormatSettings.{$ENDIF}DecimalSeparator := Ch
  end;
  if Ok then
{$ELSE}
  DecimalSeparator := '.';
  if TryStrToFloat(S, N) then
{$ENDIF}
    if Frac(N) = 0 then WriteRes('an integer number.')
    else WriteRes('a floating point number.')
  else

  begin
{$IFDEF ForIn}
    Ok := False;
    for Ch in '.-/ ' do
    begin
      Ok := TryStrToDateTime(S, D);
      if Ok then Break;
      {$IFDEF DelphiXE}FormatSettings.{$ENDIF}DateSeparator := Ch
    end;
    if Ok then
{$ELSE}
    if TryStrToDateTime(S, D) then
{$ENDIF}
      WriteRes('a date/time.')
      else WriteRes('some string.')
  end
end.

В случае каких-либо косяков или дополнений – пишите
Делаю лабы на Asm/Delphi/C++/Python/VBA(Excel): asmlabs.ru
7in вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Приложение для разных версий Windows Kapitoha Visual C++ 7 29.09.2014 09:27
Вопрос знатокам разных версий Visual Studio perplexed Общие вопросы .NET 3 23.02.2012 21:28
Особенности разных версий mutabor Microsoft Office Excel 3 21.04.2009 21:08
Delphi разных версий по разному компилируют Sergey2 Общие вопросы Delphi 3 12.01.2008 11:45