1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: c'str' now has type charptr

This commit is contained in:
Delyan Angelov 2019-12-04 12:34:06 +02:00 committed by Alexander Medvednikov
parent d8bf0df7e9
commit 9a6711fa1b
2 changed files with 15 additions and 1 deletions

View File

@ -167,10 +167,15 @@ fn (p mut Parser) name_expr() string {
} }
// Raw string (`s := r'hello \n ') // Raw string (`s := r'hello \n ')
if (name == 'r' || name == 'c') && p.peek() == .str && p.prev_tok != .str_dollar { if name == 'r' && p.peek() == .str && p.prev_tok != .str_dollar {
p.string_expr() p.string_expr()
return 'string' return 'string'
} }
// C string (a zero terminated one) C.func( c'hello' )
if name == 'c' && p.peek() == .str && p.prev_tok != .str_dollar {
p.string_expr()
return 'charptr'
}
// known_type := p.table.known_type(name) // known_type := p.table.known_type(name)
orig_name := name orig_name := name
is_c := name == 'C' && p.peek() == .dot is_c := name == 'C' && p.peek() == .dot

View File

@ -0,0 +1,9 @@
fn C.puts(charptr) int
fn test_cstring(){
h := c'world'
C.puts(c'hello')
C.puts(h)
assert true
}