PBXB64 V23 detail

Cross-frontend bridge examples

Complete historical BRIDGE EXPORT/IMPORT source pairs. The complete source/output blocks moved here from the overview and remain historical documentation; this page adds no new compiler or functional test claim.

Back to PBXB64 overviewDeutsch
One program, several frontends, shared storage

Share Variables Across Frontends

PBXB64 V23 connects its frontends at symbol level. BRIDGE EXPORT creates typed global storage, while BRIDGE IMPORT binds external storage. C receives a matching declaration; assembler code accesses the published symbol; COBOL objects keep their exact symbol names. The examples below were compiled and run with V23.

PowerBASIC ↔ C

PowerBASIC exports (inside a procedure)
BRIDGE EXPORT bridge_counter AS LONG ALIAS "bridge_counter"
bridge_counter = 41
C uses the same symbol (LONG is 64-bit: long long, not int)
extern long long bridge_counter;
bridge_counter += 1;  /* now 42 */

The complete program is sample 16 above.

COBOL ↔ PowerBASIC

COBOL owns the value (cob_shared.cbl)
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SHARED.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 SHARED-COUNT PIC S9(9) VALUE 41 GLOBAL.
       PROCEDURE DIVISION.
           STOP RUN.
PowerBASIC binds and changes it (cob_main.bas)
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN() AS LONG
    BRIDGE IMPORT shared_count AS QUAD ALIAS "SHARED-COUNT"
    PRINT shared_count
    shared_count = 42
    PRINT shared_count
    FUNCTION = 0
END FUNCTION

Build: PBXB64.exe cob_main.bas cob_shared.cbl -o cob.exe. Output: 41, then 42. COBOL is an experimental frontend.

PowerBASIC ↔ X-Code

bridge.pb
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN() AS LONG
 BRIDGE IMPORT counter AS LONG ALIAS "asm_imported_counter"
 IF counter <> 41 THEN PBMAIN = 1 : EXIT FUNCTION
 #XCODE OPT=2, SPILL=AUTO, FEATURES=BASELINE
  X.VREG value:U32
  X.LOAD V(value), DWORD PTR [counter]
  X.INC V(value)
  X.STORE DWORD PTR [counter], V(value)
 #ENDX
 IF counter <> 42 THEN PBMAIN = 2 : EXIT FUNCTION
 PBMAIN = 0
END FUNCTION

The counter lives in an assembler provider (provider.asm); the X-Code block increments it. See the X-Code page for the complete example.

Tested contract: scalar integer and floating-point types, pointers, BOOL, CURRENCY, and fixed STRINGZ * n buffers. Dynamic strings, arbitrary arrays, UDTs, and untyped aggregate writes require a dedicated bridge contract. SPR and PILOT have their own binding commands (experimental frontends; see the help).

PBXB64 is part of the PBX-Compiler package. Free for private use, cleanly licensed for business.