Fix FreeRTOS.h/semphr.h include paths for ESP-IDF (fixes #1439) (#1570)

mutex_freertos.h unconditionally included the vanilla FreeRTOS header
layout (FreeRTOS.h and semphr.h at the include root). On ESP-IDF, and
therefore Arduino-ESP32 as well since it's built on top of ESP-IDF,
these headers are nested one level deeper under freertos/, so the
unconditional include fails to compile on any ESP32 target with
ETL_TARGET_OS_FREERTOS defined.

Use __has_include to try the standard path first, fall back to the
ESP-IDF nested path, and fail with a clear #error if neither is found,
rather than a mysterious "file not found" from the compiler.

Also resolves a pre-existing include-style inconsistency in this file:
the old code mixed "FreeRTOS.h" (quotes) with <semphr.h> (angle
brackets). All includes now uniformly use angle brackets.
This commit is contained in:
Hiten Gupta 2026-08-26 20:34:46 +09:30 committed by GitHub
parent f7520ad0bd
commit e4fc36d6f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,9 +31,27 @@ SOFTWARE.
#include "../platform.h"
#include "FreeRTOS.h"
#if defined(__has_include) // Compiler supports __has_include
#if __has_include(<FreeRTOS.h>) && __has_include(<semphr.h>) // Standard FreeRTOS include layout
#include <FreeRTOS.h>
#include <semphr.h>
#elif __has_include(<freertos/FreeRTOS.h>) && __has_include(<freertos/semphr.h>) // ESP-IDF style include layout
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#else // Neither include layout found
#error "FreeRTOS.h and semphr.h not found. Please include path to FreeRTOS in your project settings"
#endif
#else
#include <FreeRTOS.h>
#include <semphr.h>
#endif
namespace etl
{
//***************************************************************************