Preprocessor Directives

#COMPILE

Syntax: #COMPILE EXE ["filename"]

Specifies the output target type. EXE produces a console executable. DLL and GUI/WINDOWS modes are recognized but explicitly rejected with a clear diagnostic (V22) until PE export/subsystem writing is implemented.

#COMPILE EXE "myapp.exe"

#DIM ALL

Syntax: #DIM ALL

Requires explicit declaration of all variables. Variables used without a LOCAL, DIM, STATIC, or GLOBAL declaration will produce an error.

#DIM ALL    ' Best practice: always declare variables

#INCLUDE / #INCLUDE ONCE / #INCLUDEONCE

Syntax: #INCLUDE "filename" | #INCLUDE ONCE "filename" | #INCLUDEONCE "filename"

Inserts the contents of another source file at the directive location. #INCLUDE ONCE and #INCLUDEONCE (V22) ensure the file is included only once, preventing duplicate declarations. Missing-file diagnostics are emitted when include-once paths fail.

Include paths are resolved relative to the current source file, then against paths specified with -I on the command line.

#INCLUDE ONCE "win32api.inc"
#INCLUDEONCE "mytypes.pbi"
#INCLUDE "helpers.inc"

Conditional Compilation (#IF / #ELSEIF / #ELSE / #ENDIF)

Syntax: #IF condition ... #ELSEIF condition ... #ELSE ... #ENDIF

Conditionally include or exclude blocks of source code at compile time (V21). Supports %DEF(name), NOT, AND, and OR in conditions. Dollar-branch variants $IF, $ELSEIF, $ELSE, $ENDIF are also supported.

#IF %DEF(PBXA64_V22)
    PRINT "V22 macros available"
#ELSEIF %DEF(DEBUG)
    PRINT "Debug build"
#ELSE
    PRINT "Release build"
#ENDIF

#DEFINE / #UNDEF

Syntax: #DEFINE name value | #UNDEF name

#DEFINE (V22) creates an object-like text-replacement macro. Every occurrence of name in subsequent source is replaced with value. #UNDEF (V21) removes a previously defined symbol. Duplicate definitions produce a diagnostic error.

#DEFINE MAX_COUNT 100
#DEFINE APP_NAME "MyApp"
LOCAL i AS LONG
FOR i = 1 TO MAX_COUNT : PRINT APP_NAME : NEXT i
#UNDEF MAX_COUNT

MACRO / END MACRO

Syntax: MACRO name(args) = expr or MACRO name(args) ... END MACRO

Macro expansion engine (V22). Supports:

Expansion is source-text based with recursion guards, depth limits, and arity diagnostics.

MACRO SAY(text)
    PRINT text
END MACRO

MACROFUNCTION Twice(x)
    MACROTEMP t
    LOCAL t AS LONG
    t = x * 2
END MACRO = t

See V22 Macro Preprocessor for full details.

Note: PBXA64 supports recursive #INCLUDE resolution with depth tracking to prevent infinite recursion. Include files use the .pbi extension by convention.

Language Block Directives

DirectiveLanguageDescription
#PCODE ... #ENDPPILOTEmbedded PILOT educational language block. Commands are lowered to PB statements.
FUNCTION PBMAIN() AS LONG
    #PCODE
    T: Hello from PILOT!
    A: What is your name?
    T: Nice to meet you, $A!
    E:
    #ENDP
    FUNCTION = 0
END FUNCTION