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

Weird typedef struct is translated incorrectly #12

Open
aladagemre opened this issue Dec 9, 2015 · 3 comments
Open

Weird typedef struct is translated incorrectly #12

aladagemre opened this issue Dec 9, 2015 · 3 comments

Comments

@aladagemre
Copy link

When generating binding for igraph see

https://github.com/igraph/igraph/blob/a98fccd3fb2a9f67551a09d4159ef268ee62c658/include/igraph_datatype.h

typedef struct igraph_s {
  igraph_integer_t n;
  igraph_bool_t directed;
  igraph_vector_t from;
  igraph_vector_t to;
  igraph_vector_t oi;
  igraph_vector_t ii;
  igraph_vector_t os;
  igraph_vector_t is;
  void *attr;
} igraph_t;

This code is translated into

struct S
  n : IntegerT
  directed : BoolT
  from : VectorT
  to : VectorT
  oi : VectorT
  ii : VectorT
  os : VectorT
  is : VectorT
  attr : Void*
end
type T = S

And then uses T* whenever functions indeed expect S_. When we replace all T_ with S*, the code works.

@asterite
Copy link
Member

I'm not sure what's the issue. Is it that T is used instead of T*? The type declaration seems fine, although maybe in those cases declaring the struct as struct T (without declaring S) should be good?

@aladagemre
Copy link
Author

when I use T.new, it says T doesn't have method new.
When I try to cast T to S, it says S can't be casted to T.

I don't know what's the reason for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants