From e4fc36d6f28c23128013f7fc3b088053d770fc08 Mon Sep 17 00:00:00 2001 From: Hiten Gupta <140595019+hiten011@users.noreply.github.com> Date: Wed, 26 Aug 2026 20:34:46 +0930 Subject: [PATCH] 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 (angle brackets). All includes now uniformly use angle brackets. --- include/etl/mutex/mutex_freertos.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/include/etl/mutex/mutex_freertos.h b/include/etl/mutex/mutex_freertos.h index 080b571a..6fde9d2c 100644 --- a/include/etl/mutex/mutex_freertos.h +++ b/include/etl/mutex/mutex_freertos.h @@ -31,8 +31,26 @@ SOFTWARE. #include "../platform.h" -#include "FreeRTOS.h" -#include +#if defined(__has_include) // Compiler supports __has_include + + #if __has_include() && __has_include() // Standard FreeRTOS include layout + #include + #include + + #elif __has_include() && __has_include() // ESP-IDF style include layout + #include + #include + + #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 + #include + +#endif namespace etl {