how to use some libraries based on cpp?

ryuhhh
Posts: 7
Joined: Sun Dec 18, 2016 6:31 am

how to use some libraries based on cpp?

Postby ryuhhh » Thu Mar 16, 2017 2:03 am

Hi, I am trying to use cpp based codes, but the build result returns some syntax errors. Is it possible to use cpp syntax with IDF?

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: how to use some libraries based on cpp?

Postby ESP_Angus » Thu Mar 16, 2017 2:35 am

It is possible. There is even a small amount of C++ code inside the IDF internals themselves.

Neil Kolban has some C++ samples/snippets/utils here: https://github.com/nkolban/esp32-snippe ... /cpp_utils

STL is available. But there are some restrictions, for example exception support is disabled.

Can you please be more specific about the errors you are seeing?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: how to use some libraries based on cpp?

Postby kolban » Thu Mar 16, 2017 3:23 am

There are also a couple of sample skeletons for C++ available here ...

https://github.com/nkolban/esp32-snippe ... letons/cpp
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ryuhhh
Posts: 7
Joined: Sun Dec 18, 2016 6:31 am

Re: how to use some libraries based on cpp?

Postby ryuhhh » Thu Mar 16, 2017 8:30 am

Thank you for the kind replies, ESP_Angus and N. Kolban.
I am using basic idf and I have built my project, after just including some .cpp files in other .c files.
Am I doing wrong?? If it needs other procedures or configurations, could you please let me know?

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: how to use some libraries based on cpp?

Postby ESP_Angus » Thu Mar 16, 2017 8:53 am

ryuhhh wrote: I am using basic idf and I have built my project, after just including some .cpp files in other .c files.
Can you post some of your code or the exact errors? It's hard to guess from just a rough description like this.

Make sure any C++ symbols (functions, etc.) called from C are marked with 'extern "C"' in their C++ declarations.

Angus

EDIT: Also files in C++ syntax must be in a .cpp file, so the build system knows to run a C++ compiler not a C compiler.

Roman_2018
Posts: 1
Joined: Sun Sep 02, 2018 11:50 am

Re: how to use some libraries based on cpp?

Postby Roman_2018 » Sun Sep 02, 2018 11:55 am

Crash cpp_utils/FreeRTOSTimer.cpp
line timersMap.insert(std::make_pair(timerHandle, this));
Who faced this?

Who is online

Users browsing this forum: No registered users and 212 guests