Compiler Directives


Syntax
CompilerIf  <constant expression>
  ...
[CompilerElse]
  ...
CompilerEndIf
Description
If the <constante expression> result is true, the code inside the CompilerIf will be compiled, else it will be totally ignored. It's useful when building multi-OSes programs to customize some programs part by using OS specific functions.

Example:

  CompilerIf #PB_Compiler_OS = #PB_OS_Linux
    ; some Linux specific code..
  CompilerEndIf

Syntax
CompilerSelect <numeric constant>
  CompilerCase
    ...
  [CompilerDefault]
    ...
CompilerEndSelect
Description
Works exactly like a regular Select : EndSelect but will tell the compiler which code should be compiled. It's useful when building multi-OSes programs to customize some programs part by using OS specific functions.

Example:

  CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_AmigaOS
      ; some Amiga specific code
    CompilerCase #PB_OS_Linux
      ; some Linux specific code
  CompilerEndSelect

Syntax
CompilerError <string constant>
Description
Generates an error, as if it was a syntax error and display the associated message. It can be useful when doing specialised routines, or to inform than a source code is not available on an particular OS.

Example:

  CompilerIf #PB_Compiler_OS = #PB_OS_AmigaOS
    CompilerError "AmigaOS isn't supported, sorry."
  CompilerElse
    CompilerError "OS supported, you can now comment me."
  CompilerEndIf


Syntax
EnableExplicit
DisableExplicit
Description
Enables or disables the explicit mode. When enabled, all the variables which are not explicitly declared with Define, Global, Protected, Static or Shared are not accepted and the compiler will raise an error. It can help to catch typo bugs.

Example:

  EnableExplicit
  
  Define a
  
  a = 20 ; Ok, as declared with 'Define'
  b = 10 ; Will raise an error here


Reserved Constants

The PureBasic compiler has several reserved constants which can be useful to the programmer:
  #PB_Compiler_OS : Determines on which OS the compiler is currently running. It can be one of the following values:
    - #PB_OS_Windows : The compiler is running on Windows
    - #PB_OS_Linux   : The compiler is running on Linux
    - #PB_OS_AmigaOS : The compiler is running on AmigaOS
    - #PB_OS_MacOS   : The compiler is running on Mac OS X
    
  #PB_Compiler_Date     : Current date, at the compile time, in the PureBasic  date format.
  #PB_Compiler_File     : Full path and name of the file being compiled, useful for debug purpose.
  #PB_Compiler_Line     : Line number of the file being compiled, useful for debug purpose.
  #PB_Compiler_Version  : Compiler version, in float format in the form '4.00'.
  #PB_Compiler_Home     : Full path of the PureBasic directory, can be useful to locate include files
  #PB_Compiler_Debugger : Set to 1 if the runtime debugger is enabled, set to 0 else. When an executable
                          is created, the debugger is always disabled (this constant will be 0).
  #PB_Compiler_Thread   : Set to 1 if the executable is compiled in thread safe mode, set to 0 else.
  #PB_Compiler_Unicode  : Set to 1 if the executable is compiled in unicode mode, set to 0 else.