crystal_lib
crystal_lib copied to clipboard
Usage of unexposed enums leads to generation of broken bindings
Unexposed enums in struct fields lead to generation of bindings with Void as field's type. As struct's fields cannot have the Void type, the generated binding is broken.
To reproduce:
$ cat <<'EOF' > /tmp/bug.h
struct st {
int a;
enum { x, y } b;
};
struct st *test();
EOF
$ crystal src/main.cr <<'EOF'
@[Include("/tmp/bug.h", prefix: %w(test))]
lib LibTest
end
EOF
lib LibTest
fun = test : St*
struct St
a : LibC::Int
b : Void
end
end
When trying to use the binding, the following error is thrown at compile time: can't use Void as a struct field type
.
I've proposed a fix for this in #67.