crystal-lang / crystal_lib

Automatic binding generator for native libraries in Crystal
138 stars 30 forks source link

Generated code fails to compile due to including multiple definitions of a data structure. #9

Closed samis closed 8 years ago

samis commented 8 years ago

(I had difficulty coming up with a good title for this.) Since #8 was fixed, the tool can now successfully parse and generate code for Eina.h which is excellent. The generated code even almost compiles without manual intervention :grinning:. However, there is one issue with the generated code: It defines the struct X___Data twice, causing it to fail to compile. The two definitions start here and here respectively.

asterite commented 8 years ago

@samis I'm not getting that definition. I use:

@[Include("stdarg.h", "eina/Eina.h", flags: "-I/Users/asterite-manas/Sandbox/efl/src/lib", prefix: %w(eina_))]
@[Link("eina")]
lib LibEina
end

Maybe I need to include more .h files? What Include are you using?

asterite commented 8 years ago

In my case /Users/asterite-manas/Sandbox/efl contains the git checkout for the efl project, https://git.enlightenment.org/core/efl.git/tree

samis commented 8 years ago

I'll perform further testing then to see if I can achieve the same result.

samis commented 8 years ago

Right. Even with the following Include it still generates the data structure:

@[Include("/home/samis/develop/efl/src/lib/eina/Eina.h", flags: "-I/home/samis/develop/efl/src/lib/", prefix: %w(eina_))]

The directory given is a fresh clone of the the git repository. I even more my system copy of the headers out of the way in order to eliminate them. I'm going to see exactly which file causes this to happen.

asterite commented 8 years ago

Oh, it's working fine on mac osx. The problem seems to happen in linux. I'll try to reproduce it, seems like a bug in nested fields.

samis commented 8 years ago

I've narrowed it down to the contents of eina_lock.h. I'll see if I can narrow it down to the specific functions causing it.

asterite commented 8 years ago

@samis Can you check now? I think I fixed it

samis commented 8 years ago

It seems to be fixed, I'll take a more indepth-look in a moment.

samis commented 8 years ago

Yep, this appears to be fixed now.

asterite commented 8 years ago

\o/