Conditional Compilation

With conditional compilation, applicable blocks of code in a program can compile while other blocks are ignored. For example, you can compare different solutions to a problem, or you can make changes specially for a given culture. Conditional compilation statements operate only at compile-time, not at run-time.

You specify conditional compilation of a block of code with the statement Const If…Else. For example, you can make POSIX-compatible and Windows versions of the same program from the same source code. You put code special to each platform between the lines that start Const If, Else, and End. Then you can use the compilation constants POSIX and WINDOWS to select the applicable code. The example that follows shows how.

Const If POSIX Then
' Unix-like code goes here.
Else If WINDOWS Then
' Windows-only code goes here.
End If

Conditional compilation constants


How it is supplied Scope
Command line Global to all modules
@Const directive Local to the module

Platform constants

ANDROIDGoogle Android
ARM_3232-bit ARM processor
ARM_6464-bit ARM processor
DESKTOPDesktop operating system
IOSApple iOS
LINUXLinux kernel
MOBILEMobile operating system
POSIXPOSIX-compliant operating system
WINDOWSMicrosoft Windows
X86_3232-bit Intel x86-compatible processor
X86_6464-bit Intel x86-compatible processor

See also