Skip to content
This repository was archived by the owner on Jun 16, 2021. It is now read-only.
This repository was archived by the owner on Jun 16, 2021. It is now read-only.

Ion cast to void** #64

@tjpalmer

Description

@tjpalmer

In ion, any pointer type seems to auto cast to void*, but they don't auto-cast to void**. For example, I have to cast from char** to void** here:

str: char* = NULL;
buf_push((:void**)&str, &val, 1);

Where I elsewhere have the following function:

func buf_push(b: void**, elem: void*, elem_size: usize) {
    buf_fit(b, 1 + buf_len(*b), elem_size);
    memcpy((:char*)*b + elem_size * buf__hdr(*b).len++, elem, elem_size);
}

If I leave out the cast, it says the following:

error: Invalid type in function call argument. Expected void**, got char**

I understand that there are bizarre edge cases for pointers on various ancient or strange systems. So maybe this is by design because of edge cases that I haven't studied well. But in my mind, this ought to work. If it should work, then it would be nice to automate it.

If it shouldn't work, then I clearly need to design the example function differently ...

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