Page 1 of 1

how to use some libraries based on cpp?

Posted: Thu Mar 16, 2017 2:03 am
by ryuhhh
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?

Re: how to use some libraries based on cpp?

Posted: Thu Mar 16, 2017 2:35 am
by ESP_Angus
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?

Re: how to use some libraries based on cpp?

Posted: Thu Mar 16, 2017 3:23 am
by kolban
There are also a couple of sample skeletons for C++ available here ...

https://github.com/nkolban/esp32-snippe ... letons/cpp

Re: how to use some libraries based on cpp?

Posted: Thu Mar 16, 2017 8:30 am
by ryuhhh
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?

Re: how to use some libraries based on cpp?

Posted: Thu Mar 16, 2017 8:53 am
by ESP_Angus
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.

Re: how to use some libraries based on cpp?

Posted: Sun Sep 02, 2018 11:55 am
by Roman_2018
Crash cpp_utils/FreeRTOSTimer.cpp
line timersMap.insert(std::make_pair(timerHandle, this));
Who faced this?