Files
gw-basic-2026/include/codegen.h
Eremey Valetov 791b5a4710 compiler: --emit-obj and --main-name for cross-language linking
Level 1 of the cross-language linking roadmap entry: produce an
object file with a renamed entry point so a BASIC program can be
linked into a larger C or Fortran build.

- src/compiler_main.c: --emit-obj runs gcc -c (compile-only,
  produces prog.o) and skips the runtime link.  --main-name NAME
  (or --main-name=NAME) is plumbed through codegen_opts_t.

- src/codegen.c: emit `int <name>(int argc, char **argv)` instead
  of always emitting `main`.  Default unchanged when --main-name
  isn't specified.

- include/codegen.h: add main_name to codegen_opts_t.

- docs/getting-started.md: new "Cross-Language Linking" section
  with C and Fortran (iso_c_binding) driver examples.

- docs/roadmap.md: three levels of cross-language linking, with
  Level 1 marked done, Level 2 (BASIC-side EXTERN declarations)
  as the next concrete step, Level 3 (BASIC SUBs as C functions)
  deferred.  Also added: FORTRAN-style WRITE / C-style PRINTF
  formatted I/O extensions, and a NumPy / DataFrame / Matplotlib-
  style standard library section as a separate sub-project track.

Verified end-to-end: a BASIC program compiled with --emit-obj
--main-name=run_basic_greet links cleanly with both a C driver
(gcc) and a Fortran driver (gfortran with iso_c_binding), and
prints the BASIC output before returning to the host.  All
72 interpreter / 68 compat / 63 compiler tests still pass.
2026-05-05 06:50:50 -04:00

796 B