diff --git a/components/newlib/CMakeLists.txt b/components/newlib/CMakeLists.txt index 6e416d8b83..df29489bad 100644 --- a/components/newlib/CMakeLists.txt +++ b/components/newlib/CMakeLists.txt @@ -4,6 +4,11 @@ if(${target} STREQUAL "linux") return() # This component is not supported by the POSIX/Linux simulator endif() +set(include_dirs "platform_include") +if(CMAKE_C_COMPILER_ID MATCHES "Clang") # TODO LLVM-330 + list(APPEND include_dirs "clang_include") +endif() + if(BOOTLOADER_BUILD) # Bootloader builds need the platform_include directory (for assert.h), but nothing else idf_component_register(INCLUDE_DIRS platform_include) @@ -29,7 +34,6 @@ set(srcs "realpath.c" "scandir.c" ) -set(include_dirs platform_include) if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND) list(APPEND srcs "port/xtensa/stdatomic_s32c1i.c") @@ -42,7 +46,7 @@ endif() list(APPEND ldfragments "newlib.lf" "system_libs.lf") idf_component_register(SRCS "${srcs}" - INCLUDE_DIRS platform_include + INCLUDE_DIRS "${include_dirs}" PRIV_INCLUDE_DIRS priv_include PRIV_REQUIRES soc spi_flash LDFRAGMENTS "${ldfragments}") diff --git a/components/newlib/platform_include/sys/dirent.h b/components/newlib/clang_include/sys/dirent.h similarity index 100% rename from components/newlib/platform_include/sys/dirent.h rename to components/newlib/clang_include/sys/dirent.h diff --git a/components/newlib/test_apps/newlib/main/test_misc.c b/components/newlib/test_apps/newlib/main/test_misc.c index a79fdf252b..bc7c076ebc 100644 --- a/components/newlib/test_apps/newlib/main/test_misc.c +++ b/components/newlib/test_apps/newlib/main/test_misc.c @@ -12,8 +12,11 @@ #include #include #include +#ifdef __clang__ // TODO LLVM-330 +#include +#else #include -#include "sys/dirent.h" +#endif #include "unity.h" #include "esp_heap_caps.h" #include "esp_vfs.h" diff --git a/components/vfs/include/esp_vfs.h b/components/vfs/include/esp_vfs.h index f7cca42e71..3fc2131b1b 100644 --- a/components/vfs/include/esp_vfs.h +++ b/components/vfs/include/esp_vfs.h @@ -21,7 +21,11 @@ #include #include #include +#ifdef __clang__ // TODO LLVM-330 #include +#else +#include +#endif #include #include "sdkconfig.h" diff --git a/components/vfs/test_apps/main/test_vfs_paths.c b/components/vfs/test_apps/main/test_vfs_paths.c index ed9ce374c7..48a41089e2 100644 --- a/components/vfs/test_apps/main/test_vfs_paths.c +++ b/components/vfs/test_apps/main/test_vfs_paths.c @@ -10,7 +10,11 @@ #include #include #include +#ifdef __clang__ // TODO LLVM-330 #include +#else +#include +#endif #include "esp_vfs.h" #include "unity.h" #include "esp_log.h" diff --git a/docs/en/migration-guides/release-5.x/5.3/gcc.rst b/docs/en/migration-guides/release-5.x/5.3/gcc.rst new file mode 100644 index 0000000000..a700db1d69 --- /dev/null +++ b/docs/en/migration-guides/release-5.x/5.3/gcc.rst @@ -0,0 +1,40 @@ +GCC +*** + +:link_to_translation:`zh_CN:[中文]` + +Common Porting Problems and Fixes +================================= + +``sys/dirent.h`` No Longer Includes Function Prototypes +------------------------------------------------------- + +Issue +^^^^^^ + +Compilation errors may occur in code that previously worked with the old toolchain. For example: + +.. code-block:: c + + #include + /* .... */ + DIR* dir = opendir("test_dir"); + /* .... */ + /** + * Compile error: + * test.c: In function 'test_opendir': + * test.c:100:16: error: implicit declaration of function 'opendir' [-Werror=implicit-function-declaration] + * 100 | DIR* dir = opendir(path); + * | ^~~~~~~ + */ + +Solution +^^^^^^^^^ + +To resolve this issue, the correct header must be included. Refactor the code like this: + +.. code-block:: c + + #include + /* .... */ + DIR* dir = opendir("test_dir"); diff --git a/docs/en/migration-guides/release-5.x/5.3/index.rst b/docs/en/migration-guides/release-5.x/5.3/index.rst index 06f5ab107b..6ee094665a 100644 --- a/docs/en/migration-guides/release-5.x/5.3/index.rst +++ b/docs/en/migration-guides/release-5.x/5.3/index.rst @@ -7,6 +7,7 @@ Migration from 5.2 to 5.3 :maxdepth: 1 bluetooth-low-energy + gcc peripherals security storage diff --git a/docs/zh_CN/migration-guides/release-5.x/5.3/gcc.rst b/docs/zh_CN/migration-guides/release-5.x/5.3/gcc.rst new file mode 100644 index 0000000000..d2312c21ef --- /dev/null +++ b/docs/zh_CN/migration-guides/release-5.x/5.3/gcc.rst @@ -0,0 +1,4 @@ +GCC +*** + +.. include:: ../../../../en/migration-guides/release-5.x/5.3/gcc.rst diff --git a/docs/zh_CN/migration-guides/release-5.x/5.3/index.rst b/docs/zh_CN/migration-guides/release-5.x/5.3/index.rst index daae13829c..3a60f2cc1d 100644 --- a/docs/zh_CN/migration-guides/release-5.x/5.3/index.rst +++ b/docs/zh_CN/migration-guides/release-5.x/5.3/index.rst @@ -7,6 +7,7 @@ :maxdepth: 1 bluetooth-low-energy + gcc peripherals security storage