BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›Language

Setup

  • Getting Started
  • Win32
  • Linux
  • macOS
  • Android
  • iOS
  • Raspberry Pi
  • NX (Switch Homebrew)
  • Custom Settings

Tutorials

  • Beginners Guide
  • OOP Tutorial
  • Network Programming
  • TCP Socket Programming

Language

  • Arrays
  • Basic Compatibility
  • Collections
  • Comments
  • Conditional Compiling
  • Constants
  • Data Types
  • Debugging
  • Enums
  • Exceptions
  • Expressions
  • Functions
  • Identifiers
  • Literals
  • Modules
  • Objects
  • Program Flow
  • Slices
  • Strings
  • User Defined Types
  • Variables
  • Advanced Topics

    • Interfacing With C
    • Memory Management
    • Pointers
    • Custom Pre/Post Compilation Scripts
    • Creating DLLs

Tools

  • MaxIDE
  • BlitzMax Make (bmk)
  • BlitzMax Compiler (bcc)
Edit

Conditional Compiling

Conditional compiling allows you to turn compiling on or off from within your program depending on the environment the program is being compiled for.

Conditional compiling works a bit like an If statement, but takes the form:

?Identifier

The ? must appear at the start of a new line, and Identifier should be one of the built-in or custom identifiers.

Built-in Identifiers

The following is a list of BlitzMax's built-in conditional compiler identifiers:

NameMeaning
DebugTrue if program is being compiled in debug mode.
ThreadedTrue if program is being compiled in threaded mode.
ReleaseTrue if program is being compiled in release mode.
Win32True if program is being compiled for the Windows operating system.
Win32x86True if program is being compiled for 32-bit Windows operating system.
Win64True if program is being compiled for 64-bit Windows operating system.
Win32x64True if program is being compiled for 64-bit Windows operating system.
MacOSTrue if program is being compiled for the macOS or iOS operating system.
MacOSX86True if program is being compiled for an 32-bit x86 macOS or iOS operating system.
MacOSX64True if program is being compiled for an 64-bit x64 macOS or iOS operating system.
MacOSarm64True if program is being compiled for an Arm64 (silicon) macOS or iOS operating system.
MacOSPPCTrue if program is being compiled for a PowerPC macOS or iOS operating system.
osxTrue if program is being compiled for macOS.
osxx86True if program is being compiled for a 32-bit x86 macOS.
osxppcTrue if program is being compiled for a PowerPC macOS.
osxx64True if program is being compiled for a 64-bit x64 macOS.
osxarm64True if program is being compiled for a Arm64 (silicon) macOS.
iosTrue if program is being compiled for iOS.
iosx86True if program is being compiled for 32-bit x86 iOS.
iosx64True if program is being compiled for 64-bit x64 iOS.
iosarmv7True if program is being compiled for a ArmV7 iOS device.
iosarm64True if program is being compiled for an Arm64 iOS device.
LinuxTrue if program is being compiled for the Linux operating system.
LinuxX86True if program is being compiled for 32-bit x86 Linux operating system.
LinuxX64True if program is being compiled for 64-bit x64 Linux operating system.
LinuxARMTrue if program is being compiled for Linux operating system running on ARM processors.
androidTrue if program is being compiled for android.
androidx86True if program is being compiled for 32-bit x86 android.
androidx64True if program is being compiled for 64-bit x64 android.
androidarmTrue if program is being compiled for android running on any ARM processor.
androidarmeabiTrue if program is being compiled for android running on ARMeabi processor.
androidarmeabiv7aTrue if program is being compiled for android running on ARMeabi-v7a processor.
androidarm64v8aTrue if program is being compiled for android running on ARM64-v8a processor.
raspberrypiTrue if program is being compiled for RaspberryPi
raspberrypiARMTrue if program is being compiled for ARM based RaspberryPi
emscriptenTrue if program is using emuscripten compiler
emscriptenjsTrue if program is compiled into javascript using emuscripten compiler
X86True if program is being compiled for x86-based 32-bit CPU.
X64True if program is being compiled for x64-based 64-bit CPU.
PPCTrue if program is being compiled for PowerPC CPU.
armTrue if program is being compiled for any ARM CPU
armeabiTrue if program is being compiled for ARMeabi CPU
armeabiv7aTrue if program is being compiled for ARMeabi-v7a CPU
arm64v8aTrue if program is being compiled for ARM64-v8a
jsTrue if program is being compiled for javascript
armv7True if program is being compiled for ARM-v7
arm64True if program is being compiled for ARM64
ptr32True if program being compiled for systems with 32-bit pointers
ptr64True if program being compiled for systems with 64-bit pointers
BigEndianTrue if program is being compiled for a big endian CPU.
LittleEndianTrue if program is being compiled for a little endian CPU.
openglesTrue if program is being compiled for platform that uses OpenGL ES
bmxngTrue if program is being compiled using BlitzMax-NG

Identifier may also be preceded by Not to invert the result.

An ? on its own always turns compiling on.

Conditional Expressions

BlitzMax-NG also allows for conditional expressions such as ?x64 and raspberrypi, where several identifiers can be chained together using and, or and not

For example:

?Debug
    ' Any code here is only compiled in debug mode.
?Not Debug
    ' Any code here is only compiled in release mode.
?Debug and x64
    ' Any code here is only compiled in debug mode and if being compiled for a 64 bit system
?
    ' Code here is always compiled.
← CommentsConstants →
  • Built-in Identifiers
  • Conditional Expressions
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
ResourcesSyntaxBomb Forums
More
GitHubStarChat on Discord
Copyright © 2023 Bruce A Henderson