-3

LVGL library looks very promising as an alternative to Qt (C++), but it's C based. Is there a way to automate wrapping it into a C++ modern interface or at least with minimum modification each new release?

In the javascript world, react has a mechanism called react-reconciler to automate wrapping libraries, so is there something similar for C to C++?

1 Answer 1

3

Most of the time you can just use the the C library by including the C header file. You might have to add an extern "C" {} around the include if the header doesn't already have that itself.

But if you mean updating the interface to modern C++ standards, using std::uniq_ptr, std::shared_ptr, std::vector and so on then you are out of luck. Changing between those and C types can't be simply automated since they add meaning to the interface that simply doesn't exist within C, it can't be inferred from the header.

On the other hand the library interface isn't likely to change. At least not much. Normally future versions should only have additions, anything else requires a SONAME change and requires all software to be recompiled against the new lib at a minimum. So if you can't live with the C interface you would only have to write a wrapper once and then just do minor additions for updates.

Sign up to request clarification or add additional context in comments.

2 Comments

extern C is OK when you want to use small parts maybe. But I'm searching for something that parses code and may propose a better C++ interface where RAII is used for example.
Me too, me too. It just isn't something that works automatically.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.