Skip to content

Additional metadata for pointer union types #9

@marler8997

Description

@marler8997

This is a follow up to the discussion here: microsoft/win32metadata#623

The issue is that some win32 pointer parameters accept more than just pointers, but Zig verifies pointer alignment which prevents these non-pointer values from being passed. For example, calling CreateWindowEx with the return value of RegisterClass for lpClassName will trigger a pointer alignment issue when performing an alignCast from ATOM to LPCSTR.

It was also discussed that changing these pointer parameters to a union type can break the ABI since some ABI's treat pointers and structure types differently, even if the structure itself is made up of a single pointer value.

So given these constraints, the solution I came up with for Zig is to maintain additional metadata that indicates which of these pointer parameters or fields can accept other non-pointer values and add align(1) to those pointer types. If another projection would also like this additional metadata, then this extra data could be upstreamed and turned into a new attribute in the Microsoft supplied metadata. Note that since this is a possibility, I should make the implementation as similar to an attribute as I can.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions