diff --git a/cmd/tools/vtest-cleancode.v b/cmd/tools/vtest-cleancode.v index 4e1225e330..954604d708 100644 --- a/cmd/tools/vtest-cleancode.v +++ b/cmd/tools/vtest-cleancode.v @@ -35,7 +35,6 @@ const ( 'vlib/v/tests/interop_test.v', /* bad comment formatting */ 'vlib/v/tests/string_interpolation_test.v' /* TODO byteptr: &byte.str() behaves differently than byteptr.str() */, 'vlib/v/gen/js/tests/js.v', /* local `hello` fn, gets replaced with module `hello` aliased as `hl` */ - 'examples/c_interop_wkhtmltopdf.v' /* &charptr --> &&char */, ] vfmt_verify_list = [ 'cmd/', diff --git a/examples/c_interop_wkhtmltopdf.v b/examples/c_interop_wkhtmltopdf.v index 5d210e0bcc..ddd56b57d2 100644 --- a/examples/c_interop_wkhtmltopdf.v +++ b/examples/c_interop_wkhtmltopdf.v @@ -53,7 +53,7 @@ fn main() { // init init := C.wkhtmltopdf_init(0) println('wkhtmltopdf_init: $init') - version := int(C.wkhtmltopdf_version()) + version := unsafe { cstring_to_vstring(&char(C.wkhtmltopdf_version())) } println('wkhtmltopdf_version: $version') global_settings := C.wkhtmltopdf_create_global_settings() println('wkhtmltopdf_create_global_settings: ${voidptr(global_settings)}') @@ -71,14 +71,15 @@ fn main() { error_code := C.wkhtmltopdf_http_error_code(converter) println('wkhtmltopdf_http_error_code: $error_code') if result { - data := &charptr(0) - size := C.wkhtmltopdf_get_output(converter, data) + pdata := &char(0) + ppdata := &pdata + size := C.wkhtmltopdf_get_output(converter, voidptr(ppdata)) println('wkhtmltopdf_get_output: $size bytes') mut file := os.open_file('./google.pdf', 'w+', 0o666) or { println('ERR: $err') return } - wrote := unsafe { file.write_ptr(data, size) } + wrote := unsafe { file.write_ptr(pdata, size) } println('write_bytes: $wrote [./google.pdf]') file.flush() file.close()