dbsoft / dwindows

Dynamic Windows Library Mirror
Other
8 stars 1 forks source link

C++ binding? #1

Closed ghost closed 1 year ago

ghost commented 2 years ago

I found there is Go binding and FreeBASIC binding but there isn't a C++ binding? I tried to build dwtest.c with g++ and even if I passed -fpermissive it's still unable to build. Gui library like this usually has C++ binding (e.g: gtk has gtkmm). Iup library has a simple C++ wrapper called iup_plus. Please consider adding a C++ binding. Thanks.

dbsoft commented 2 years ago

I have not made C++ specific bindings, but since the API is C you can call them from C++ without modification.

If there is a demand for C++ encapsulation I can put that on my TODO list.

And don't compile it with g++ ... just compile the library with C, then include dw.h and call the APIs from C++ code.

peprnp commented 2 years ago

If there is a demand for C++ encapsulation I can put that on my TODO list.

Please consider adding C++ binding. Thank you. Your library is pretty low level I think (the same level as GTK). Another reason for a C++ wrapper is it will be OOP. I come from Qt so I have no objections to this.

ghost commented 2 years ago

I have not made C++ specific bindings, but since the API is C you can call them from C++ without modification.

Have you actually tried to do this or just speak theoretically?

If there is a demand for C++ encapsulation I can put that on my TODO list.

Definitely. Please add C++ wrapper.

dbsoft commented 2 years ago

Have you actually tried to do this or just speak theoretically?

I have done it... I had to add #ifdef __cplusplus to the header to allow this to work.

The Microsoft Edge linkage is in C++ and it includes dw.h so it can call the C API calls... you can see these changes from 2019 here:

https://github.com/dbsoft/dwindows/commit/3fbfa5c111640b5d3a108a3af7fb768237b29e80

dbsoft commented 2 years ago

I'm adding this to be for 3.3, however I am not sure yet if the C++ wrapper will be included in the dwindows project itself or in a separate project. With the other bindings it makes sense for them to be separate, however C++ can be included together with the C API logically.

ghost commented 2 years ago

I'm adding this to be for 3.3, however I am not sure yet if the C++ wrapper will be included in the dwindows project itself or in a separate project. With the other bindings it makes sense for them to be separate, however C++ can be included together with the C API logically.

I think it should be simply a dw_plus.hpp header included with dwindows itself.

dbsoft commented 1 year ago

Looks like the original poster might be gone, but I was planning on building a C++ binding for the upcoming release... are there any requests for what C++ standard to target with it?

The base C API is designed for maximum portability, but the language bindings don't need that... but I can keep the binding compatible back to IBM VisualAge C++ or focus on one of the newer C++ standards: 03, 11, 14, 17, etc....

Thoughts?

dbsoft commented 1 year ago

Ok well, I have started work on the bindings will try to have them ready for 3.3.

dbsoft commented 1 year ago

I have the initial version of the bindings available for evaluation, bindings in: https://github.com/dbsoft/dwindows/blob/master/dw.hpp and a port of dwtest.c to C++ is in: https://github.com/dbsoft/dwindows/blob/master/dwtestoo.cpp

Thoughts, suggestions, etc?

dbsoft commented 1 year ago

I'll be continuing to work on and enhance this, but the basics are there... so closing this issue. If you have any specific changes to the now existing bindings, please open a separate issue.