lvgl / lvgl

Embedded graphics library to create beautiful UIs for any MCU, MPU and display type.
https://lvgl.io
MIT License
16.29k stars 3.19k forks source link

discussion about C++ code in LVGL #6267

Closed kdschlosser closed 3 months ago

kdschlosser commented 4 months ago

Introduce the problem

While this isn't necessarily a problem it is going to cause some grief with things like the documentation and possibly bindings.

We have started to write c++ code in LVGL. The documentation build system is not able to handle reading C++ so that causes some problems. It also causes problems with bindings like the micropython binding. This is because the micropython binding is only able to read C header files and not C++ header files. Things like ThorVG end up being inaccessible to people that use the binding.

Proposal

Write proper C wrappers around any libraries that are used in LVGL that are written in C++. Create C header files that will allow the documentation build system to work properly and create C source files that wrap the C++ libraries code so it is able to be used in all bindings.

There are limitations with what is able to be done using automatic code generation when building a binding and this is one of those limitations that there is really not a way around other than getting rid of the automatic generation of the code and writing it manually.

kdschlosser commented 4 months ago

header files that contain C++ code should have the extension hpp and the source files should be cpp. This allows for easy identification of what header files contain C++ code.

Ideally there should be no inclusion of any c++ code into any public C header files. If this is done it trips things up with both the documentation and possibly in binding code generation.

C47D commented 4 months ago

Hi,

Would it be done incrementally (one pull request per library) or in a single huge pull request?

kdschlosser commented 4 months ago

This is just for discussion purposes. Because we are starting to add a lot of C++ code into the project we need to make sure we think about the bindings that rely on C code in order to generate the proper binding code.

This is to make the developers aware of a potential road block that is starting to happen.

kisvegabor commented 4 months ago

Ideally there should be no inclusion of any c++ code into any public C header files. If this is done it trips things up with both the documentation and possibly in binding code generation.

There shouldn't be. lv_lottie.h contains only C things. Or are we leaking C++ to headers somewhere else?

lvgl-bot commented 3 months ago

We need some feedback on this issue.

Now we mark this as "stale" because there was no activity here for 14 days.

Remove the "stale" label or comment else this will be closed in 7 days.

lvgl-bot commented 3 months ago

As there was no activity here for a while we close this issue. But don't worry, the conversation is still here and you can get back to it at any time.

So feel free to comment if you have remarks or ideas on this topic.