mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
cgen: fix #preinclude, add test case for #postinclude too
This commit is contained in:
parent
d82757abd9
commit
305c56dbf7
@ -570,6 +570,7 @@ pub fn gen(files []&ast.File, mut table ast.Table, pref_ &pref.Preferences) GenO
|
||||
}
|
||||
b.write_string2('\n// V comptime_definitions:\n', g.comptime_definitions.str())
|
||||
b.write_string2('\n// V typedefs:\n', g.typedefs.str())
|
||||
b.write_string2('\n // V preincludes:\n', g.preincludes.str())
|
||||
b.write_string2('\n// V cheaders:', g.cheaders.str())
|
||||
if g.pcs_declarations.len > 0 {
|
||||
b.write_string2('\n// V profile counters:\n', g.pcs_declarations.str())
|
||||
|
1
vlib/v/gen/c/testdata/postinclude_example.out
vendored
Normal file
1
vlib/v/gen/c/testdata/postinclude_example.out
vendored
Normal file
@ -0,0 +1 @@
|
||||
Hi from V, p: 42
|
10
vlib/v/gen/c/testdata/postinclude_example.vv
vendored
Normal file
10
vlib/v/gen/c/testdata/postinclude_example.vv
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
module no_main
|
||||
|
||||
#postinclude "@VEXEROOT/vlib/v/gen/c/testdata/postinclude_header.h"
|
||||
|
||||
@[markused]
|
||||
pub fn f(p int) int {
|
||||
assert p == 42
|
||||
C.printf(c'Hi from V, p: %d\n', p)
|
||||
return 987
|
||||
}
|
7
vlib/v/gen/c/testdata/postinclude_header.h
vendored
Normal file
7
vlib/v/gen/c/testdata/postinclude_header.h
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
int main( void ) {
|
||||
int res = no_main__f(42);
|
||||
assert(res == 987);
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user