Skip to content

Commit e54af19

Browse files
committed
examples: fix -cstrict compilation of c_interop_wkhtmltopdf.v
1 parent 9553c5a commit e54af19

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cmd/tools/vtest-cleancode.v

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const (
3535
'vlib/v/tests/interop_test.v', /* bad comment formatting */
3636
'vlib/v/tests/string_interpolation_test.v' /* TODO byteptr: &byte.str() behaves differently than byteptr.str() */,
3737
'vlib/v/gen/js/tests/js.v', /* local `hello` fn, gets replaced with module `hello` aliased as `hl` */
38-
'examples/c_interop_wkhtmltopdf.v' /* &charptr --> &&char */,
3938
]
4039
vfmt_verify_list = [
4140
'cmd/',

examples/c_interop_wkhtmltopdf.v

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn main() {
5353
// init
5454
init := C.wkhtmltopdf_init(0)
5555
println('wkhtmltopdf_init: $init')
56-
version := int(C.wkhtmltopdf_version())
56+
version := unsafe { cstring_to_vstring(&char(C.wkhtmltopdf_version())) }
5757
println('wkhtmltopdf_version: $version')
5858
global_settings := C.wkhtmltopdf_create_global_settings()
5959
println('wkhtmltopdf_create_global_settings: ${voidptr(global_settings)}')
@@ -71,14 +71,15 @@ fn main() {
7171
error_code := C.wkhtmltopdf_http_error_code(converter)
7272
println('wkhtmltopdf_http_error_code: $error_code')
7373
if result {
74-
data := &charptr(0)
75-
size := C.wkhtmltopdf_get_output(converter, data)
74+
pdata := &char(0)
75+
ppdata := &pdata
76+
size := C.wkhtmltopdf_get_output(converter, voidptr(ppdata))
7677
println('wkhtmltopdf_get_output: $size bytes')
7778
mut file := os.open_file('./google.pdf', 'w+', 0o666) or {
7879
println('ERR: $err')
7980
return
8081
}
81-
wrote := unsafe { file.write_ptr(data, size) }
82+
wrote := unsafe { file.write_ptr(pdata, size) }
8283
println('write_bytes: $wrote [./google.pdf]')
8384
file.flush()
8485
file.close()

0 commit comments

Comments
 (0)