defined c functions do not warn if param is of name `interface`
Describe the bug
Compile the included code on linux, you will need wayland-client installed.
Reproduction Steps
#flag linux -I/usr/include
#flag linux -lwayland-client
#include <wayland-client-protocol.h>
#include <wayland-util.h>
pub struct C.wl_interface {
pub:
name &char
version int
method_count int
// methods &C.wl_message
event_count int
// events &C.wl_message
}
pub struct C.wl_registry {}
fn C.wl_registry_bind(wl_registry &C.wl_registry, name u32, interface &C.wl_interface, version u32) voidptr
fn main() {
registry := C.wl_registry{}
bound := C.wl_registry_bind(®istry, u32(0), 0, u32(0))
}
Expected Behavior
Should recognize that the function wl_registry_bind takes 4 parameters.
Current Behavior
test.v:21:2: warning: unused variable: `bound`
19 | fn main() {
20 | registry := C.wl_registry{}
21 | bound := C.wl_registry_bind(®istry, u32(0), 0, u32(0))
| ~~~~~
22 | }
test.v:21:13: error: expected 5 arguments, but got 4
19 | fn main() {
20 | registry := C.wl_registry{}
21 | bound := C.wl_registry_bind(®istry, u32(0), 0, u32(0))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 | }
Details: have (&C.wl_registry, u32, int literal, u32)
want (&C.wl_registry, u32, main.interface, &C.wl_interface, u32)
Possible Solution
We are getting an extra type called main.interface which is suspicious. Not sure what the cause is.
Additional Information/Context
No response
V version
V 0.4.12 b052af8
Environment details (OS name and version, etc.)
| V full version | V 0.4.12 2a121047627b93badb74be8332ca2ea63a0bdb5d.b052af8 |
|---|---|
| OS | linux, "CachyOS" |
| Processor | 16 cpus, 64bit, little endian, AMD Ryzen 7 5700G with Radeon Graphics |
| Memory | 5.41GB/13.55GB |
| V executable | /home/dylan/Repos/v/v |
| V last modified time | 2025-11-27 15:34:00 |
| V home dir | OK, value: /home/dylan/Repos/v |
| VMODULES | OK, value: /home/dylan/.vmodules |
| VTMP | OK, value: /tmp/v_1000 |
| Current working dir | OK, value: /home/dylan |
| Git version | git version 2.52.0 |
| V git status | weekly.2025.47-74-g64078cfb |
| .git/config present | true |
| cc version | cc (GCC) 15.2.1 20251112 |
| gcc version | gcc (GCC) 15.2.1 20251112 |
| clang version | clang version 21.1.6 |
| tcc version | tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux) |
| tcc git status | thirdparty-linux-amd64 696c1d84 |
| emcc version | N/A |
| glibc version | ldd (GNU libc) 2.42 |
[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.
Same happens if we explicitly pass the interface:
test.v:24:13: error: expected 5 arguments, but got 4
22 | c'name', 0, 1, 1
23 | }
24 | bound := C.wl_registry_bind(®istry, u32(0), &iface, u32(0))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 | }
Details: have (&C.wl_registry, u32, &C.wl_interface, u32)
want (&C.wl_registry, u32, main.interface, &C.wl_interface, u32)
Never mind, the actual issue is there is that the variable is called interface which is a keyword. There is no warning for this.