wit-bindgen icon indicating copy to clipboard operation
wit-bindgen copied to clipboard

C: generating no-op functions

Open MendyBerger opened this issue 4 months ago • 0 comments

This might not be a huge issue, but probably worth pointing out anyway.

Given the following wit:

package my-namespace:my-package;

interface my-interface {
    type my-type = u32;
    record my-record {
        my-field: option<my-type>,
    }
}

world my-world {
    import my-interface;
}

With command:

wit-bindgen c wit --world my-world

Generates function:

void my_world_option_my_type_free(my_world_option_my_type_t *ptr) {
  if (ptr->is_some) {
  }
}

The if block seems extra if nothing is going to happen inside.

If I remove the option around my-type the free function is not being generated at all.

MendyBerger avatar Nov 25 '25 20:11 MendyBerger