mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(newlib): get rid of dirent.h in favor of toolchain
This commit is contained in:
parent
4ac07fc575
commit
31a951268a
@ -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}")
|
||||
|
@ -12,8 +12,11 @@
|
||||
#include <errno.h>
|
||||
#include <sys/param.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __clang__ // TODO LLVM-330
|
||||
#include <sys/dirent.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#include "sys/dirent.h"
|
||||
#endif
|
||||
#include "unity.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_vfs.h"
|
||||
|
@ -21,7 +21,11 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/termios.h>
|
||||
#include <sys/poll.h>
|
||||
#ifdef __clang__ // TODO LLVM-330
|
||||
#include <sys/dirent.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include "sdkconfig.h"
|
||||
|
||||
|
@ -10,7 +10,11 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/fcntl.h>
|
||||
#ifdef __clang__ // TODO LLVM-330
|
||||
#include <sys/dirent.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#include "esp_vfs.h"
|
||||
#include "unity.h"
|
||||
#include "esp_log.h"
|
||||
|
40
docs/en/migration-guides/release-5.x/5.3/gcc.rst
Normal file
40
docs/en/migration-guides/release-5.x/5.3/gcc.rst
Normal file
@ -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 <sys/dirent.h>
|
||||
/* .... */
|
||||
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 <dirent.h>
|
||||
/* .... */
|
||||
DIR* dir = opendir("test_dir");
|
@ -7,6 +7,7 @@ Migration from 5.2 to 5.3
|
||||
:maxdepth: 1
|
||||
|
||||
bluetooth-low-energy
|
||||
gcc
|
||||
peripherals
|
||||
security
|
||||
storage
|
||||
|
4
docs/zh_CN/migration-guides/release-5.x/5.3/gcc.rst
Normal file
4
docs/zh_CN/migration-guides/release-5.x/5.3/gcc.rst
Normal file
@ -0,0 +1,4 @@
|
||||
GCC
|
||||
***
|
||||
|
||||
.. include:: ../../../../en/migration-guides/release-5.x/5.3/gcc.rst
|
@ -7,6 +7,7 @@
|
||||
:maxdepth: 1
|
||||
|
||||
bluetooth-low-energy
|
||||
gcc
|
||||
peripherals
|
||||
security
|
||||
storage
|
||||
|
Loading…
x
Reference in New Issue
Block a user