-
Notifications
You must be signed in to change notification settings - Fork 250
Closed
Description
Consider the following interface:
// test.wit
enum error {
success,
failure
}
option-test: function() -> expected<option<string>, error>Generating the C import bindings:
$ wit-bindgen c --import test.wit
Then, trying to compile results in the following error:
test_error_t test_option_test(test_option_string_t *ret0);
^
1 error generated.
Looking at the generated bindings, test_option_string_t is clearly missing:
#ifndef __BINDINGS_TEST_H
#define __BINDINGS_TEST_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
typedef struct {
char *ptr;
size_t len;
} test_string_t;
void test_string_set(test_string_t *ret, const char *s);
void test_string_dup(test_string_t *ret, const char *s);
void test_string_free(test_string_t *ret);
typedef uint8_t test_error_t;
#define TEST_ERROR_SUCCESS 0
#define TEST_ERROR_FAILURE 1
test_error_t test_option_test(test_option_string_t *ret0);
#ifdef __cplusplus
}
#endif
#endifChanging the interface to:
option-test: function() -> expected<option<string>, _>This time, the header file includes the structure definition:
typedef struct {
// `true` if `val` is present, `false` otherwise
bool tag;
test_string_t val;
} test_option_string_t;Metadata
Metadata
Assignees
Labels
No labels