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:
parent
d8bf0df7e9
commit
9a6711fa1b
@ -167,10 +167,15 @@ fn (p mut Parser) name_expr() string {
|
||||
}
|
||||
|
||||
// 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()
|
||||
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)
|
||||
orig_name := name
|
||||
is_c := name == 'C' && p.peek() == .dot
|
||||
|
9
vlib/compiler/tests/cstrings_test.v
Normal file
9
vlib/compiler/tests/cstrings_test.v
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user