test(C0.1): pin named #import c block — name namespaces decls, #define/#flags reach the unit's compile

This commit is contained in:
agra
2026-06-12 16:38:02 +03:00
parent d739c5bf11
commit 2808d5df82
6 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
// Pins the NAMED `#import c` block (PLAN-C C0.1): the block's name
// namespaces the decls synthesized from `#include`, and `#define` /
// `#flags` entries reach the unit's clang invocation — the macro decides
// what cdef_value answers.
#import "modules/std.sx";
cu :: #import c {
#include "1618-cimport-named-defines/cdef.h";
#source "1618-cimport-named-defines/cdef.c";
#define "CDEF_BASE=42";
#flags "-O2";
};
main :: () -> i32 {
print("value = {}\n", cu.cdef_value());
print("doubled = {}\n", cu.cdef_doubled(21));
0
}

View File

@@ -0,0 +1,6 @@
#include "cdef.h"
#ifndef CDEF_BASE
#define CDEF_BASE 1
#endif
int cdef_value(void) { return CDEF_BASE; }
int cdef_doubled(int x) { return x * 2; }

View File

@@ -0,0 +1,5 @@
#ifndef CDEF_H
#define CDEF_H
int cdef_value(void);
int cdef_doubled(int x);
#endif

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,2 @@
value = 42
doubled = 42