	// Call C registration
	cName := C.CString(impl.Name())
	defer C.free(unsafe.Pointer(cName))

	var cErr *C.char
	rc := C.{{ c_function }}(
		cName,
		&vtable,
		unsafe.Pointer(uintptr(handle)),
		&cErr,
	)

	if rc != 0 {
		msg := "failed to register {{ trait_name }}"
		if cErr != nil {
			msg = C.GoString(cErr)
			C.{{ ffi_prefix }}_free_string(cErr)
		}
		handle.Delete()
		return fmt.Errorf("%s", msg)
	}

	// Store handle by name for later cleanup on unregister
	{{ trait_snake }}Registry.store(impl.Name(), handle)
	return nil
