Conditional Defines

The Elements compiler provides the following defines that can be used with {$IF} (Oxygene) and #ifdef (C# and Swift) and related [Compiler Directives](Compiler Directives) to do conditional compilation based on compiler version or target platform. The defines listed here are provided intrinsically by the compiler, but they can be joined by further user defines set up in the Project Properties or defined in code via the {$DEFINE} (Oxygene) or #define (C# and Swift) Compiler Directive.

The ELEMENTS Define

The ELEMENTS define can and should be used to conditionally compile for Oxygene, RemObjects C# and Silver vs. other Pascal, C#, Swift or Jabva dialects:

  • ELEMENTS - Version 7.0 and up, recommended
  • OXYGENE - Version 3.0 and up
  • ADRENOCHROME - Legacy, version 1.0 and up
  • CHROME - Legacy, version 1.0 and up

Versions

The following defines are available to check for specific compiler versions. As a general rule of thumb, the defines ending with a version number are only defined for this version and will disappear for future major versions, while defines ending in UP will remain forever, and can be used to check for "version x and later".

  • ELEMENTS100 - Version 10 only
  • ELEMENTS90 - Version 9.x only
  • ELEMENTS80 - Version 8.x only
  • ELEMENTS70 - Version 7.x only
  • ELEMENTS100UP - Version 10 and up
  • ELEMENTS90UP - Version 9.0 and up
  • ELEMENTS83UP - Version 8.3 and up
  • ELEMENTS80UP - Version 8.0 and up
  • ELEMENTS70UP - Version 7.0 and up
  • OXYGENE100 - Version 10 only
  • OXYGENE90 - Version 9.x only
  • OXYGENE80 - Version 8.x only
  • OXYGENE70 - Version 7.x only
  • OXYGENE60 - Version 6.x only
  • OXYGENE50 - Version 5.x only
  • OXYGENE100UP - Version 10 and up
  • OXYGENE90UP - Version 9.0 and up
  • OXYGENE80UP - Version 8.0 and up
  • OXYGENE70UP - Version 7.0 and up
  • OXYGENE60UP - Version 6.0 and up
  • OXYGENE50UP - Version 5.0 and up
  • OXYGENE40UP - Version 4.0 and up
  • OXYGENE30UP - Version 3.0 and up
  • VER100 - Version 10 only
  • VER90 - Version 9.x only
  • VER80 - Version 8.x only
  • VER70 - Version 7.x only
  • VER60 - Version 6.x only
  • VER50 - Version 5.x only
  • VER100UP - Version 10 and up
  • VER90UP - Version 9.0 and up
  • VER80UP - Version 8.0 and up
  • VER70UP - Version 7.0 and up
  • VER60UP - Version 6.0 and up
  • VER50UP - Version 5.0 and up
  • VER40UP - Version 4.0 and up
  • VER30UP - Version 3.0 and up

Platforms

One of the following will be defined, depending on the target platform.

Also, defines based on the internal edition code names will be defined as well:

Sub-Platforms

One of the following will be defined, depending on the sub-platform of your target:

  • For Cocoa:
    • MACOS
    • IOS
    • TVOS
    • WATCHOS
    • SIMULATOR - defined along with one of the above, when building for the iOS, tvOS or watchOS Simulator instead of for a physical device.
  • For Java:
    • ANDROID - defined when building against the Android SDK (i.e. android.jar instead of the regular JDK).
  • For Island:
    • LINUX – for the Linux and Android sup-platforms
    • WINDOWS – for the Windows sup-platform
    • ANDROID – for the Android sup-platform
    • WEBASSEMBLY – for the WebAssembly sup-platform

Note that ANDROID will be defined both in Java based and NDK-based Android projects!

Features

  • GENERICS - Defined if Generics are supported, currently on .NET 2.0 and higher, Java, Island and as of Elements 7.1 also for Cocoa.
  • GC - Defined if the platform uses Garbage Collection, i.e. on .NET and Java on Version 6 and up, as well as on Island.
  • ARC - Defined if the platform uses Automated Reference Counting, i.e. on Cocoa.

Compiler Platform

On .NET projects only, the following two defines can be used to distinguish whether the project is being compiled on the Microsoft .NET platform (DOTNET) or on Mono (MONO). Note that this define only indicates what platform the compiler is being run on, since no distinction is made between .NET, Mono or other CLR implementations for the target output.

  • DOTNET - On .NET only, if the compiler is running on Windows on the Microsoft .NET runtime
  • MONO - On .NET only, if the compiler is running on the Mono runtime

Framework-driven Defines

On Elements for Cocoa, the following defines are passed to or defined by FXGen and will thus be available via the imported SDK's rtl.fx reference. It is important to note that none of the defines below (in contrast to COCOA and TOFFEE) are defined by the compiler; in theory, a different rtl.fx (such as a custom-import with FXGen) could provide different defines.

  • __LITTLE_ENDIAN__
  • __APPLE__
  • __APPLE_CC__
  • __MACH__
  • __OBJC__
  • __OBJC2__
  • __TOFFEE__
  • JSC_OBJC_API_ENABLED

Mac OS X (64-bit)

  • __X86_64__
  • __SSE__
  • __SSE2__
  • __LP64__
  • OSX
  • MACOS

iOS (32-bit)

  • __ARM__
  • IOS

iOS (64-bit)

  • __ARM__
  • __ARM64__
  • __LP64__
  • IOS

iOS Simulator (32-bit)

  • __I386__
  • __SSE__
  • __SSE2__
  • IOS
  • IOSSIMULATOR
  • SIMULATOR

iOS Simulator (64-bit)

  • __X86_64__
  • __SSE__
  • __SSE2__
  • __LP64__
  • IOS
  • IOSSIMULATOR
  • SIMULATOR

watchOS (32-bit)

  • __ARM__
  • WATCHOS

watchOS Simulator (32-bit)

  • __I386__
  • __SSE__
  • __SSE2__
  • WATCHOS
  • WATCHOSSIMULATOR
  • SIMULATOR

tvOS (64-bit)

  • __ARM__
  • __ARM64__
  • __LP64__
  • TVOS

tvOS Simulator (64-bit)

  • __X86_64__
  • __SSE__
  • __SSE2__
  • __LP64__
  • TVOS
  • TVOSSIMULATOR
  • SIMULATOR

Note that the above list might change or expand for future SDK versions or for different future platform combinations (such as they did for 64-bit iOS, and may for a future ARM-based Mac OS X).

In addition, any value-less #defines and any #defines with a value of "1" that are present in the Objective-C headers will also be defined if the respective namespaces are in use.

For example, TARGET_OS_IPHONE and TARGET_IPHONE_SIMULATOR are two handy defines to check for iOS (vs. OS X), and TARGET_OS_WATCH can be used to check for watchOS, just as TARGET_OS_TV can be used for tvOS. Caveat: TARGET_OS_MAC is also defined on iOS and watchOS, and TARGET_OS_IPHONE is also on watchOS and tvOS!