DescriptionCompilerIf <constant expression> ... [CompilerElseIf] ... [CompilerElse] ... CompilerEndIf
If the <constant 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. The And and Or Keywords can be used in <constant expression> to combine multiple conditions.
CompilerIf #PB_Compiler_OS = #PB_OS_Linux And #PB_Compiler_Processor = #PB_Processor_x86 ; some Linux and x86 specific code. CompilerEndIf
DescriptionCompilerSelect <numeric constant> CompilerCase <numeric constant> ... [CompilerDefault] ... CompilerEndSelect
Works like a regular Select : EndSelect except that only one numeric value is allowed per case. It 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.
CompilerSelect #PB_Compiler_OS CompilerCase #PB_OS_MacOS ; some Mac OS X specific code CompilerCase #PB_OS_Linux ; some Linux specific code CompilerEndSelect
DescriptionCompilerError <string constant>
Generates an error, as if it was a syntax error and display the associated message. It can be useful when doing specialized routines, or to inform a source code is not available on an particular OS.
CompilerIf #PB_Compiler_OS = #PB_OS_Linux CompilerError "Linux isn't supported, sorry." CompilerElse CompilerError "OS supported, you can now comment me." CompilerEndIf
Enables or disables the explicit mode. When enabled, all the variables which are not explicitly declared with Define, Global, Protected or Static are not accepted and the compiler will raise an error. It can help to catch typo bugs.
EnableExplicit Define a a = 20 ; Ok, as declared with 'Define' b = 10 ; Will raise an error here
Enables or disables the inline assembler. When enabled, all the assembler keywords are available directly in the source code, see the inline assembler section for more information.
; x86 assembly example ; Test = 10 EnableASM MOV dword [v_Test],20 DisableASM Debug Test ; Will be 20
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_MacOS : The compiler is running on Mac OS X #PB_Compiler_Processor : Determines the processor type for which the program is created. It can be one of the following: #PB_Processor_x86 : x86 processor architecture (also called IA-32 or x86-32) #PB_Processor_x64 : x86-64 processor architecture (also called x64, AMD64 or Intel64) #PB_Compiler_ExecutableFormat : Determines executable format. It can be one of the following: #PB_Compiler_Executable : Regular executable #PB_Compiler_Console : Console executable (have an effect only on Windows, other act like a regular executable) #PB_Compiler_DLL : Shared DLL (dynlib on MacOS X and shared object on Linux) #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_FilePath : Full path of the file being compiled, useful for debug purpose. #PB_Compiler_Filename : Filename (without path) 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_Procedure: Current procedure name, if the line is inside a procedure. #PB_Compiler_Module : Current module name, if the line is inside a module. #PB_Compiler_Version : Compiler version, in integer format in the form '420' for 4.20. #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. #PB_Compiler_LineNumbering : Set to 1 if the executable is compiled with OnError line numbering support, set to 0 else. #PB_Compiler_InlineAssembly: Set to 1 if the executable is compiled with inline assembly support, set to 0 else. #PB_Compiler_EnableExplicit: Set to 1 if the executable is compiled with enable explicit support, set to 0 else. #PB_Compiler_IsMainFile : Set to 1 if the file being compiled is the main file, set to 0 else. #PB_Compiler_IsIncludeFile : Set to 1 if the file being compiled has been included by another file, set to 0 else.