Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of unexposed enums leads to generation of broken bindings #66

Open
olbat opened this issue Mar 1, 2020 · 1 comment · Fixed by WhoAteDaCake/crystal_lib#4 · May be fixed by #67
Open

Usage of unexposed enums leads to generation of broken bindings #66

olbat opened this issue Mar 1, 2020 · 1 comment · Fixed by WhoAteDaCake/crystal_lib#4 · May be fixed by #67

Comments

@olbat
Copy link
Contributor

olbat commented Mar 1, 2020

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.

@olbat
Copy link
Contributor Author

olbat commented Mar 1, 2020

I've proposed a fix for this in #67.

@olbat olbat changed the title Unexposed enums lead to generation of broken bindings Usage of unexposed enums leads to generation of broken bindings Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant