c++ projects in IDF?
c++ projects in IDF?
Is there an easy way to create a new cpp project in the idf? I'm trying to migrate a sketch from Android IDE, which is generally working there, to IDF. I can see some reference to using the naming convention "main/main.cpp" and changes to the make files, but I can't make it work. Any documentation?
-
- Posts: 4
- Joined: Fri Nov 26, 2021 12:50 pm
Re: c++ projects in IDF?
Just use and rename your main.c to main.cpp
Code: Select all
extern "C" void app_main()
-
- Posts: 4
- Joined: Mon Dec 06, 2021 4:09 pm
Re: c++ projects in IDF?
app_main() is called by C code. If you compile your main file as cpp this function name will be mangled. The solution is to define app_main as extern "C" so it can be called from C. That's all. We use C++ in all our projects.
Just note that exceptions are disabled by default. You can enable them in menuconfig.
Also if you want to use modern C++ features you can set C++ version to C++17 in CMakeLists.txt:
Code: Select all
extern "C" void app_main(void)
{
}
Also if you want to use modern C++ features you can set C++ version to C++17 in CMakeLists.txt:
Code: Select all
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Who is online
Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 132 guests