mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tests: use a platform neutral module with C declarations (sokol.audio), instead of time
in private_redeclaration_of_C_timeval.vv .
This commit is contained in:
parent
94d6670e8f
commit
b1a14c6cf7
@ -170,7 +170,7 @@ fn read_wav_file_samples(fpath string) ?[]f32 {
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
if ch.chunk_type == [u8(`d`), `a`, `t`, `a`]! {
|
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')
|
return error('`data` chunk should be after `fmt ` chunk')
|
||||||
}
|
}
|
||||||
// eprintln('`fmt ` chunk: $rf\n`data` chunk: $ch')
|
// eprintln('`fmt ` chunk: $rf\n`data` chunk: $ch')
|
||||||
|
@ -98,8 +98,8 @@ fn C.saudio_expect() int
|
|||||||
fn C.saudio_push(frames &f32, num_frames int) int
|
fn C.saudio_push(frames &f32, num_frames int) int
|
||||||
|
|
||||||
// setup - setup sokol-audio
|
// setup - setup sokol-audio
|
||||||
pub fn setup(desc C.saudio_desc) {
|
pub fn setup(desc &C.saudio_desc) {
|
||||||
C.saudio_setup(&desc)
|
C.saudio_setup(desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// shutdown - shutdown sokol-audio
|
// shutdown - shutdown sokol-audio
|
||||||
|
@ -2,7 +2,5 @@ module module_with_redeclaration
|
|||||||
|
|
||||||
pub const used = 1
|
pub const used = 1
|
||||||
|
|
||||||
struct C.timeval {
|
struct C.saudio_desc {
|
||||||
tv_sec u64 // Seconds.
|
|
||||||
tv_usec u64 // Microseconds.
|
|
||||||
}
|
}
|
||||||
|
28
vlib/v/checker/tests/private_redeclaration_of_C_struct.out
Normal file
28
vlib/v/checker/tests/private_redeclaration_of_C_struct.out
Normal file
@ -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 | }
|
@ -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)
|
||||||
|
}
|
@ -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 | }
|
|
@ -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)
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user