Breush / odin-binding-generator

An Odin library to convert a C header file into an Odin binding file.
MIT License
41 stars 20 forks source link

Is there a way to convert C++ headerfiles into Odin? #12

Closed Joe23232 closed 3 years ago

Joe23232 commented 3 years ago

Is there a way to convert C++ headerfiles into Odin?

Breush commented 3 years ago

Hi @Joe23232 ,

According to https://github.com/odin-lang/Odin/wiki/Binding-to-C it is not made easy to bind with C++ directly.

People usually write a small C wrapper that allow accessing the C++ API with C-like functions.

Does that make sense?

Joe23232 commented 3 years ago

Hi @Joe23232 ,

According to https://github.com/odin-lang/Odin/wiki/Binding-to-C it is not made easy to bind with C++ directly.

People usually write a small C wrapper that allow accessing the C++ API with C-like functions.

Does that make sense?

Hey man,

Yes it does make sense, but is it then somehow possible to write a small C wrapper to access the C++ API and then convert the C wrapper file into Odin, that way Odin would be accessing the C++ API?

I am kinda new to programming so I don't quite know how this kind of stuff works.

Breush commented 3 years ago

To answer simply: yes, it is possible. Once you have your C API (hiding the C++ details) you can either write the Odin binding by hand or use odin-binding-generator to automate this process.

But I am not aware of any tool that can automate the creation of your C API from the C++. As far as I know, it has to be done by hand. Which, depending on the scope of the C++ project, it can be pretty time-consuming.

However:

Hope it helps you. :)

Joe23232 commented 3 years ago

Thanks man it does help :)