2010. március 17., szerda

An almost complete include file to detect different versions of Borland compilers


Problem/Question/Abstract:

An almost complete include file to detect different versions of Borland compilers

Answer:

File: Compilers.inc

Include file to determine which compiler is currently being used to build the project/ component. This file uses ideas from Brad Stowers DFS.inc file (www.delphifreestuff.com). The following symbols are defined:

// COMPILER_1    : Kylix/Delphi/BCB 1.x is the compiler.
// COMPILER_1_UP : Kylix/Delphi/BCB 1.x or higher is the compiler.
// COMPILER_2    : Kylix/Delphi 2.x or BCB 1.x is the compiler.
// COMPILER_2_UP : Kylix/Delphi 2.x or higher, or BCB 1.x or higher is the compiler.
// COMPILER_3    : Kylix/Delphi/BCB 3.x is the compiler.
// COMPILER_3_UP : Kylix/Delphi/BCB 3.x or higher is the compiler.
// COMPILER_4    : Kylix/Delphi/BCB 4.x is the compiler.
// COMPILER_4_UP : Kylix/Delphi/BCB 4.x or higher is the compiler.
// COMPILER_5    : Kylix/Delphi/BCB 5.x is the compiler.
// COMPILER_5_UP : Kylix/Delphi/BCB 5.x or higher is the compiler.
// COMPILER_6    : Kylix/Delphi/BCB 6.x is the compiler.
// COMPILER_6_UP : Kylix/Delphi/BCB 6.x or higher is the compiler.
// COMPILER_7    : Kylix/Delphi/BCB 7.x is the compiler.
// COMPILER_7_UP : Kylix/Delphi/BCB 7.x or higher is the compiler.
//
// Only defined if Windows is the target:
// CPPB        : Any version of BCB is being used.
// CPPB_1      : BCB v1.x is being used.
// CPPB_3      : BCB v3.x is being used.
// CPPB_3_UP   : BCB v3.x or higher is being used.
// CPPB_4      : BCB v4.x is being used.
// CPPB_4_UP   : BCB v4.x or higher is being used.
// CPPB_5      : BCB v5.x is being used.
// CPPB_5_UP   : BCB v5.x or higher is being used.
//
// Only defined if Windows is the target:
// DELPHI      : Any version of Delphi is being used.
// DELPHI_1    : Delphi v1.x is being used.
// DELPHI_2    : Delphi v2.x is being used.
// DELPHI_2_UP : Delphi v2.x or higher is being used.
// DELPHI_3    : Delphi v3.x is being used.
// DELPHI_3_UP : Delphi v3.x or higher is being used.
// DELPHI_4    : Delphi v4.x is being used.
// DELPHI_4_UP : Delphi v4.x or higher is being used.
// DELPHI_5    : Delphi v5.x is being used.
// DELPHI_5_UP : Delphi v5.x or higher is being used.
// DELPHI_6    : Delphi v6.x is being used.
// DELPHI_6_UP : Delphi v6.x or higher is being used.
// DELPHI_7    : Delphi v7.x is being used.
// DELPHI_7_UP : Delphi v7.x or higher is being used.
//
// Only defined if Linux is the target:
// KYLIX       : Any version of Kylix is being used.
// KYLIX_1     : Kylix 1.x is being used.
// KYLIX_1_UP  : Kylix 1.x or higher is being used.

{$IFDEF Win32}
{$IFDEF VER150}
{$DEFINE COMPILER_7}
{$DEFINE DELPHI}
{$DEFINE DELPHI_7}
{$ENDIF}

{$IFDEF VER140}
{$DEFINE COMPILER_6}
{$DEFINE DELPHI}
{$DEFINE DELPHI_6}
{$ENDIF}

{$IFDEF VER130}
{$DEFINE COMPILER_5}
{$IFDEF BCB}
{$DEFINE CPPB}
{$DEFINE CPPB_5}
{$ELSE}
{$DEFINE DELPHI}
{$DEFINE DELPHI_5}
{$ENDIF}
{$ENDIF}

{$IFDEF VER125}
{$DEFINE COMPILER_4}
{$DEFINE CPPB}
{$DEFINE CPPB_4}
{$ENDIF}

{$IFDEF VER120}
{$DEFINE COMPILER_4}
{$DEFINE DELPHI}
{$DEFINE DELPHI_4}
{$ENDIF}

{$IFDEF VER110}
{$DEFINE COMPILER_3}
{$DEFINE CPPB}
{$DEFINE CPPB_3}
{$ENDIF}

{$IFDEF VER100}
{$DEFINE COMPILER_3}
{$DEFINE DELPHI}
{$DEFINE DELPHI_3}
{$ENDIF}

{$IFDEF VER93}
{$DEFINE COMPILER_2} // C_UP_UPB v1 compiler is really v2
{$DEFINE CPPB}
{$DEFINE CPPB_1}
{$ENDIF}

{$IFDEF VER90}
{$DEFINE COMPILER_2}
{$DEFINE DELPHI}
{$DEFINE DELPHI_2}
{$ENDIF}

{$IFDEF VER80}
{$DEFINE COMPILER_1}
{$DEFINE DELPHI}
{$DEFINE DELPHI_1}
{$ENDIF}

{$IFDEF COMPILER_1}
{$DEFINE COMPILER_1_UP}
{$ENDIF}

{$IFDEF COMPILER_2}
{$DEFINE COMPILER_1_UP}
{$DEFINE COMPILER_2_UP}
{$ENDIF}

{$IFDEF COMPILER_3}
{$DEFINE COMPILER_1_UP}
{$DEFINE COMPILER_2_UP}
{$DEFINE COMPILER_3_UP}
{$ENDIF}

{$IFDEF COMPILER_4}
{$DEFINE COMPILER_1_UP}
{$DEFINE COMPILER_2_UP}
{$DEFINE COMPILER_3_UP}
{$DEFINE COMPILER_4_UP}
{$ENDIF}

{$IFDEF COMPILER_5}
{$DEFINE COMPILER_1_UP}
{$DEFINE COMPILER_2_UP}
{$DEFINE COMPILER_3_UP}
{$DEFINE COMPILER_4_UP}
{$DEFINE COMPILER_5_UP}
{$ENDIF}

{$IFDEF COMPILER_6}
{$DEFINE COMPILER_1_UP}
{$DEFINE COMPILER_2_UP}
{$DEFINE COMPILER_3_UP}
{$DEFINE COMPILER_4_UP}
{$DEFINE COMPILER_5_UP}
{$DEFINE COMPILER_6_UP}
{$ENDIF}

{$IFDEF COMPILER_7}
{$DEFINE COMPILER_1_UP}
{$DEFINE COMPILER_2_UP}
{$DEFINE COMPILER_3_UP}
{$DEFINE COMPILER_4_UP}
{$DEFINE COMPILER_5_UP}
{$DEFINE COMPILER_6_UP}
{$DEFINE COMPILER_7_UP}
{$ENDIF}

{$IFDEF DELPHI_2}
{$DEFINE DELPHI_2_UP}
{$ENDIF}

{$IFDEF DELPHI_3}
{$DEFINE DELPHI_2_UP}
{$DEFINE DELPHI_3_UP}
{$ENDIF}

{$IFDEF DELPHI_4}
{$DEFINE DELPHI_2_UP}
{$DEFINE DELPHI_3_UP}
{$DEFINE DELPHI_4_UP}
{$ENDIF}

{$IFDEF DELPHI_5}
{$DEFINE DELPHI_2_UP}
{$DEFINE DELPHI_3_UP}
{$DEFINE DELPHI_4_UP}
{$DEFINE DELPHI_5_UP}
{$ENDIF}

{$IFDEF DELPHI_6}
{$DEFINE DELPHI_2_UP}
{$DEFINE DELPHI_3_UP}
{$DEFINE DELPHI_4_UP}
{$DEFINE DELPHI_5_UP}
{$DEFINE DELPHI_6_UP}
{$ENDIF}

{$IFDEF DELPHI_7}
{$DEFINE DELPHI_2_UP}
{$DEFINE DELPHI_3_UP}
{$DEFINE DELPHI_4_UP}
{$DEFINE DELPHI_5_UP}
{$DEFINE DELPHI_6_UP}
{$DEFINE DELPHI_7_UP}
{$ENDIF}

{$IFDEF CPPB_3}
{$DEFINE CPPB_3_UP}
{$ENDIF}

{$IFDEF CPPB_4}
{$DEFINE CPPB_3_UP}
{$DEFINE CPPB_4_UP}
{$ENDIF}

{$IFDEF CPPB_5}
{$DEFINE CPPB_3_UP}
{$DEFINE CPPB_4_UP}
{$DEFINE CPPB_5_UP}
{$ENDIF}

{$IFDEF CPPB_3_UP}
// C++ Builder requires this if you use Delphi components in run-time packages.
{$OBJEXPORTALL On}
{$ENDIF}

{$ELSE (not Windows)}
// Linux is the target
{$DEFINE KYLIX}
{$DEFINE KYLIX_1}
{$DEFINE KYLIX_1_UP}
{$ENDIF}

Nincsenek megjegyzések:

Megjegyzés küldése