fixed size array with const length (`[N]int`)
parent
be323e2fb6
commit
aed22a57e3
|
@ -39,6 +39,7 @@ jobs:
|
|||
run: sudo ./v symlink
|
||||
- name: Set up pg database
|
||||
run: |
|
||||
brew services start postgresql
|
||||
psql -U postgres -c 'create database customerdb;'
|
||||
psql -d customerdb -f examples/database/pg/mydb.sql
|
||||
- name: Test v->c
|
||||
|
|
|
@ -22,6 +22,7 @@ mut:
|
|||
includes []string
|
||||
thread_args []string
|
||||
consts []string
|
||||
const_defines []string
|
||||
fns []string
|
||||
so_fns []string
|
||||
consts_init []string
|
||||
|
|
|
@ -75,8 +75,13 @@ fn (p mut Parser) get_type2() Type{
|
|||
for p.tok == .lsbr {
|
||||
p.check(.lsbr)
|
||||
// [10]int
|
||||
if p.tok == .number {
|
||||
if p.tok == .number || (p.tok == .name && !p.inside_const) {
|
||||
if p.tok == .name {
|
||||
typ += '[${p.mod}__$p.lit]'
|
||||
|
||||
} else {
|
||||
typ += '[$p.lit]'
|
||||
}
|
||||
p.next()
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -316,6 +316,7 @@ pub fn (v mut V) compile() {
|
|||
}
|
||||
// All definitions
|
||||
mut def := strings.new_builder(10000)// Avoid unnecessary allocations
|
||||
def.writeln(cgen.const_defines.join_lines())
|
||||
$if !js {
|
||||
def.writeln(cgen.includes.join_lines())
|
||||
def.writeln(cgen.typedefs.join_lines())
|
||||
|
|
|
@ -708,7 +708,7 @@ fn (p mut Parser) const_decl() {
|
|||
// Do not do this when building a module, otherwise the consts
|
||||
// will not be accessible.
|
||||
if p.pref.build_mode != .build_module && is_compile_time_const(p.cgen.cur_line) {
|
||||
p.cgen.consts << '#define $name $p.cgen.cur_line'
|
||||
p.cgen.const_defines << '#define $name $p.cgen.cur_line'
|
||||
p.cgen.resetln('')
|
||||
p.fgen_nl()
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue