test(C3.3): #define/#flags reach a unit consumed only by hand-curated #foreign decls

This commit is contained in:
agra
2026-06-12 17:09:07 +03:00
parent 1bad29e72e
commit 44f4aab51c
5 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
// `#define`/`#flags` reach a unit whose ONLY consumer is hand-curated
// `#foreign` decls (PLAN-C C3.3) — no `#include`, no auto-synthesis:
// the macro decides what the unit-bound decl answers.
#import "modules/std.sx";
unit :: #import c {
#define "UNIT_BASE=33";
#flags "-O2";
#source "1622-cimport-unit-bound-defines/unit.c";
};
unit_answer :: () -> i32 #foreign unit "unit_answer";
main :: () -> i32 {
print("unit answer = {}\n", unit_answer());
0
}

View File

@@ -0,0 +1,4 @@
#ifndef UNIT_BASE
#define UNIT_BASE 1
#endif
int unit_answer(void) { return UNIT_BASE; }

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@
unit answer = 33