PlatformIO ESP32 with ESP-IDF 最小 C++ 示例

默认情况下,当你初始化 PlatformIO ESP-IDF 项目时,它会生成 main.c - 不是 C++ 而是纯 C 文件

此最小示例使用 main.cpp(你可以直接重命名 main.c - 查看 如何在 ESP32 / esp-idf 上使用 C++ main.cpp 与 PlatformIO 获取详细步骤列表)。

main.cpp
#include <cstdio>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>

extern "C" {
    void app_main(void);
}

void app_main() {
    while(true) {
        printf("Hello PlatformIO!\n");
        // Wait for one second
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}

Check out similar posts by category: C/C++, ESP8266/ESP32, PlatformIO