Using C++ library in esp-idf
Posted: Mon Jun 28, 2021 11:29 pm
Hi all,
I have found a LoRaWAN library that works in the esp-idf and I am trying to integrate it into the ulp-riscv example, however I am having trouble figuring out how to handle the c++ components of the library.
I have seen other posts trying to get C++ to work like this:
https://www.esp32.com/viewtopic.php?f=1 ... a51990bc02
There is a few examples of how to use C in C++, but not the other way around.
The error I'm getting is:
I have tried using some extern "C" as shown here:
https://isocpp.org/wiki/faq/mixing-c-and-cpp
But yet to have much success, I am likely just approaching it wrong...
Has anyone had success with a similar problem?
Cheers
I have found a LoRaWAN library that works in the esp-idf and I am trying to integrate it into the ulp-riscv example, however I am having trouble figuring out how to handle the c++ components of the library.
I have seen other posts trying to get C++ to work like this:
https://www.esp32.com/viewtopic.php?f=1 ... a51990bc02
There is a few examples of how to use C in C++, but not the other way around.
The error I'm getting is:
Code: Select all
P_PLATFORM -MD -MT esp-idf/main/CMakeFiles/__idf_main.dir/ulp_riscv_example_main.c.obj -MF esp-idf\main\CMakeFiles\__idf_main.dir\ulp_riscv_example_main.c.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/ulp_riscv_example_main.c.obj -c ../main/ulp_riscv_example_main.c
In file included from ../main/ulp_riscv_example_main.c:22:
../main/include/TheThingsNetwork.h:139:5: error: unknown type name 'TTNSpreadingFactor'
TTNSpreadingFactor spreadingFactor;
^~~~~~~~~~~~~~~~~~
../main/include/TheThingsNetwork.h:143:5: error: unknown type name 'TTNBandwidth'
TTNBandwidth bandwidth;
^~~~~~~~~~~~
../main/include/TheThingsNetwork.h:168:1: error: unknown type name 'class'
class TheThingsNetwork
^~~~~
../main/include/TheThingsNetwork.h:169:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
ninja: build stopped: subcommand failed.
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command cmake --build ." terminated with exit code: 1.
https://isocpp.org/wiki/faq/mixing-c-and-cpp
But yet to have much success, I am likely just approaching it wrong...
Has anyone had success with a similar problem?
Cheers