Skip to content

V compiler rejects duplicate-identical C type aliases (blocks revosw/windows bindings) #4

Description

@ylluminate

Problem: V's builtin (vlib/builtin/builtin_windows.c.v) defines:

pub type C.BOOL = int
pub type C.HANDLE = voidptr
pub type C.HWND = voidptr
pub type C.HINSTANCE = voidptr
// ... 12 more

The revosw/windows module (auto-generated from Microsoft winmd metadata) also defines these same types with identical definitions in win32/foundation/mod.c.v. V's checker rejects this:

error: cannot register alias `C.HANDLE`, another type with this name exists

Why it matters: revosw/windows is the only V project providing typed Win32 API bindings generated from Microsoft's official metadata. Any V project that imports it on Windows gets this error because the foundation module is pulled in transitively by every other Win32 module.

Reproduction:

// test.v
import revosw.windows.win32.ui.windowsandmessaging
fn main() {}
v run test.v  // → "cannot register alias C.HANDLE"

Where the check lives: vlib/v/checker/checker.v around line 629 — unconditional rejection of duplicate C type registration.

Requested fix (either one):

  1. V compiler: If a pub type C.X = T is registered and a second pub type C.X = T arrives with the same underlying type, silently accept it instead of erroring
  2. V compiler: Provide a flag or attribute like @[allow_redefinition] for C type aliases

Secondary issue: vlib/dl/dl_windows.c.v:28 tries to return C.BOOL (which is int) as V bool - this is a type mismatch in V's own stdlib on Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions