test(C3.3): #define/#flags reach a unit consumed only by hand-curated #foreign decls
This commit is contained in:
17
examples/1622-cimport-unit-bound-defines.sx
Normal file
17
examples/1622-cimport-unit-bound-defines.sx
Normal 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
|
||||||
|
}
|
||||||
4
examples/1622-cimport-unit-bound-defines/unit.c
Normal file
4
examples/1622-cimport-unit-bound-defines/unit.c
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#ifndef UNIT_BASE
|
||||||
|
#define UNIT_BASE 1
|
||||||
|
#endif
|
||||||
|
int unit_answer(void) { return UNIT_BASE; }
|
||||||
1
examples/expected/1622-cimport-unit-bound-defines.exit
Normal file
1
examples/expected/1622-cimport-unit-bound-defines.exit
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
1
examples/expected/1622-cimport-unit-bound-defines.stdout
Normal file
1
examples/expected/1622-cimport-unit-bound-defines.stdout
Normal file
@@ -0,0 +1 @@
|
|||||||
|
unit answer = 33
|
||||||
Reference in New Issue
Block a user