Skip to content

[Tip] Use of CPP on ESP8266 examples

Kwang-Hui edited this page Dec 22, 2022 · 1 revision

Example applications for ESP chipsets are written in C while iot-core library already extern "C" statement for C++ preprocessor.

So if you want to make example source code to c++. Please refer issue #121 thread.

  • renamed the main.c to main.cpp
  • added CXXFLAGS += -fpermissive to my Makefile in the apps/esp8266/xxxxx_example directory (otherwise the compiler complains about unsafe castings)
  • put extern "C" {} around the #include "iot_uart_cli.h" and #include "iot_cli_cmd.h"
  • put extern "C" {} around app_main function
  • included this library which has been patched to support the esp8266 rtos sdk: https://github.com/THKDev/NeoPixelBus_ESP8266_RTOS