-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++ Support doesn't work #5695
Comments
Kind of, I would suggest that when this is resolved one should look into if the fix has affected #1205 or #4028. #4028 looks like a feature-request for supporting more C++ features. #1205 looks like a report that C++ is broken when -fpermissive is not applied (I have already tested that neither -fpermissive or -fno-permissive resolves the issues reported here). |
Note that you don't need to use the BT_MESH_ADV_CONN macro if you don't want to. Creating a "normal" struct bt_mesh_adv_param stack variable and passing a reference to that to bt_mesh_adv_start() should make a C++ compiler happy. |
As I was trying to port my freeRTOS C++ applications, I'm sad this has stagnated and that I won't be able to use the full functionality/abstraction zephyr has to offer. Given issues like this still exist, I think it's only fair to ATLEAST put a caveat in the documentation, which seems to sell zephyr as conveniently c++ compatible (it's not at the moment), or just remove the claim completely. |
Nope, sorry. This references Bluetooth specifically so #18551 blocks it. |
Problem
When trying to use Zephyr with C++ I noticed that a lot of the headers contain code that isn't valid in C++ and causes compile errors when included in C++ files. I noticed this mainly with the Bluetooth subsystem but I wouldn't be surprised if other parts of are affected too as I haven't tested them.
So even though my examples focus on Bluetooth this issue concerns Zephyr as a whole.
The documentation claims that Zephyr has C++ support, but at the moment not even the most basic things work.
After asking on IRC about this @SebastianBoe confirmed those problems and submitted PR #5642 with some small fixes. While that was a first step in the right direction a lot more has to be done still.
As far as I know there are absolutely no automated tests in Zephyr for C++ compatibility at the moment. I would suggest changing that to properly ensure C++ compatibility in the future. If possible maybe just reuse/adopt existing C tests and additionally compile them in C++.
Solution
Minimal Example
The following configuration was used in
prj.conf
:Built with the current master branch of zephyr and zephyr-sdk-0.9.2 for the nrf52 platform using the following commands:
This minimal example will generate the following errors:
Full Examples
For additional, more complete code samples just use the various (Bluetooth) examples that Zephyr already provides and compile them as C++ by changing the extensions of the files as well as in the
CMakeFiles.txt
to.cpp
.I would suggest starting with
bluetooth/beacon
which is the most simple example and working our way up from there to more complex examples.The text was updated successfully, but these errors were encountered: