diff --git a/examples/sokol/sounds/wav_player.v b/examples/sokol/sounds/wav_player.v index b781be3ac2..b73fd83d56 100644 --- a/examples/sokol/sounds/wav_player.v +++ b/examples/sokol/sounds/wav_player.v @@ -170,7 +170,7 @@ fn read_wav_file_samples(fpath string) ?[]f32 { } // if ch.chunk_type == [u8(`d`), `a`, `t`, `a`]! { - if rf == 0 { + if unsafe { rf == 0 } { return error('`data` chunk should be after `fmt ` chunk') } // eprintln('`fmt ` chunk: $rf\n`data` chunk: $ch') diff --git a/vlib/sokol/audio/audio.v b/vlib/sokol/audio/audio.v index 700ff21a55..0cf18497b2 100644 --- a/vlib/sokol/audio/audio.v +++ b/vlib/sokol/audio/audio.v @@ -98,8 +98,8 @@ fn C.saudio_expect() int fn C.saudio_push(frames &f32, num_frames int) int // setup - setup sokol-audio -pub fn setup(desc C.saudio_desc) { - C.saudio_setup(&desc) +pub fn setup(desc &C.saudio_desc) { + C.saudio_setup(desc) } // shutdown - shutdown sokol-audio diff --git a/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.v b/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.v index 7545677a5d..7613cea293 100644 --- a/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.v +++ b/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.v @@ -2,7 +2,5 @@ module module_with_redeclaration pub const used = 1 -struct C.timeval { - tv_sec u64 // Seconds. - tv_usec u64 // Microseconds. +struct C.saudio_desc { } diff --git a/vlib/v/checker/tests/private_redeclaration_of_C_struct.out b/vlib/v/checker/tests/private_redeclaration_of_C_struct.out new file mode 100644 index 0000000000..d714aab2f9 --- /dev/null +++ b/vlib/v/checker/tests/private_redeclaration_of_C_struct.out @@ -0,0 +1,28 @@ +vlib/sokol/audio/audio.v:86:26: error: struct `C.saudio_desc` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `sokol.audio` + 84 | fn C.saudio_userdata() voidptr + 85 | + 86 | fn C.saudio_query_desc() C.saudio_desc + | ~~~~~~~~~~~~~ + 87 | + 88 | fn C.saudio_sample_rate() int +vlib/sokol/audio/audio.v:101:19: error: struct `C.saudio_desc` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `sokol.audio` + 99 | + 100 | // setup - setup sokol-audio + 101 | pub fn setup(desc &C.saudio_desc) { + | ^ + 102 | C.saudio_setup(desc) + 103 | } +vlib/sokol/audio/audio.v:121:16: error: struct `C.saudio_desc` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `sokol.audio` + 119 | + 120 | // query - return a copy of the original saudio_desc struct + 121 | pub fn query() C.saudio_desc { + | ~~~~~~~~~~~~~ + 122 | return C.saudio_query_desc() + 123 | } +vlib/v/checker/tests/private_redeclaration_of_C_struct.vv:7:10: error: struct `C.saudio_desc` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `main` + 5 | + 6 | fn main() { + 7 | sd := C.saudio_desc{} + | ~~~~~~~~~~~~~ + 8 | audio.setup(sd) + 9 | } diff --git a/vlib/v/checker/tests/private_redeclaration_of_C_struct.vv b/vlib/v/checker/tests/private_redeclaration_of_C_struct.vv new file mode 100644 index 0000000000..0318ee2b19 --- /dev/null +++ b/vlib/v/checker/tests/private_redeclaration_of_C_struct.vv @@ -0,0 +1,9 @@ +import module_with_redeclaration as mr +import sokol.audio + +const used = mr.used + +fn main() { + sd := C.saudio_desc{} + audio.setup(sd) +} diff --git a/vlib/v/checker/tests/private_redeclaration_of_C_timeval.out b/vlib/v/checker/tests/private_redeclaration_of_C_timeval.out deleted file mode 100644 index cce34e2e47..0000000000 --- a/vlib/v/checker/tests/private_redeclaration_of_C_timeval.out +++ /dev/null @@ -1,14 +0,0 @@ -vlib/time/time.c.v:90:11: error: struct `C.timeval` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `time` - 88 | return C.GetTickCount() - 89 | } $else { - 90 | ts := C.timeval{} - | ~~~~~~~~~ - 91 | C.gettimeofday(&ts, 0) - 92 | return i64(ts.tv_sec * u64(1000) + (ts.tv_usec / u64(1000))) -vlib/v/checker/tests/private_redeclaration_of_C_timeval.vv:9:10: error: struct `C.timeval` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `main` - 7 | dump(time.now()) // ensure `time` is used - 8 | // - 9 | ts := C.timeval{} - | ~~~~~~~~~ - 10 | dump(ts) - 11 | } diff --git a/vlib/v/checker/tests/private_redeclaration_of_C_timeval.vv b/vlib/v/checker/tests/private_redeclaration_of_C_timeval.vv deleted file mode 100644 index 50d2c056cc..0000000000 --- a/vlib/v/checker/tests/private_redeclaration_of_C_timeval.vv +++ /dev/null @@ -1,11 +0,0 @@ -import module_with_redeclaration as mr -import time - -const used = mr.used - -fn main() { - dump(time.now()) // ensure `time` is used - // - ts := C.timeval{} - dump(ts) -}