kopia lustrzana https://github.com/espressif/esp-idf
feat(newlib): get rid of dirent.h in favor of toolchain
rodzic
4ac07fc575
commit
31a951268a
|
@ -4,6 +4,11 @@ if(${target} STREQUAL "linux")
|
||||||
return() # This component is not supported by the POSIX/Linux simulator
|
return() # This component is not supported by the POSIX/Linux simulator
|
||||||
endif()
|
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)
|
if(BOOTLOADER_BUILD)
|
||||||
# Bootloader builds need the platform_include directory (for assert.h), but nothing else
|
# Bootloader builds need the platform_include directory (for assert.h), but nothing else
|
||||||
idf_component_register(INCLUDE_DIRS platform_include)
|
idf_component_register(INCLUDE_DIRS platform_include)
|
||||||
|
@ -29,7 +34,6 @@ set(srcs
|
||||||
"realpath.c"
|
"realpath.c"
|
||||||
"scandir.c"
|
"scandir.c"
|
||||||
)
|
)
|
||||||
set(include_dirs platform_include)
|
|
||||||
|
|
||||||
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
||||||
list(APPEND srcs "port/xtensa/stdatomic_s32c1i.c")
|
list(APPEND srcs "port/xtensa/stdatomic_s32c1i.c")
|
||||||
|
@ -42,7 +46,7 @@ endif()
|
||||||
list(APPEND ldfragments "newlib.lf" "system_libs.lf")
|
list(APPEND ldfragments "newlib.lf" "system_libs.lf")
|
||||||
|
|
||||||
idf_component_register(SRCS "${srcs}"
|
idf_component_register(SRCS "${srcs}"
|
||||||
INCLUDE_DIRS platform_include
|
INCLUDE_DIRS "${include_dirs}"
|
||||||
PRIV_INCLUDE_DIRS priv_include
|
PRIV_INCLUDE_DIRS priv_include
|
||||||
PRIV_REQUIRES soc spi_flash
|
PRIV_REQUIRES soc spi_flash
|
||||||
LDFRAGMENTS "${ldfragments}")
|
LDFRAGMENTS "${ldfragments}")
|
||||||
|
|
|
@ -12,8 +12,11 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#ifdef __clang__ // TODO LLVM-330
|
||||||
|
#include <sys/dirent.h>
|
||||||
|
#else
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include "sys/dirent.h"
|
#endif
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
#include "esp_vfs.h"
|
#include "esp_vfs.h"
|
||||||
|
|
|
@ -21,7 +21,11 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/termios.h>
|
#include <sys/termios.h>
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
|
#ifdef __clang__ // TODO LLVM-330
|
||||||
#include <sys/dirent.h>
|
#include <sys/dirent.h>
|
||||||
|
#else
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,11 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/fcntl.h>
|
#include <sys/fcntl.h>
|
||||||
|
#ifdef __clang__ // TODO LLVM-330
|
||||||
#include <sys/dirent.h>
|
#include <sys/dirent.h>
|
||||||
|
#else
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif
|
||||||
#include "esp_vfs.h"
|
#include "esp_vfs.h"
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
|
@ -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
|
:maxdepth: 1
|
||||||
|
|
||||||
bluetooth-low-energy
|
bluetooth-low-energy
|
||||||
|
gcc
|
||||||
peripherals
|
peripherals
|
||||||
security
|
security
|
||||||
storage
|
storage
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
GCC
|
||||||
|
***
|
||||||
|
|
||||||
|
.. include:: ../../../../en/migration-guides/release-5.x/5.3/gcc.rst
|
|
@ -7,6 +7,7 @@
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|
||||||
bluetooth-low-energy
|
bluetooth-low-energy
|
||||||
|
gcc
|
||||||
peripherals
|
peripherals
|
||||||
security
|
security
|
||||||
storage
|
storage
|
||||||
|
|
Ładowanie…
Reference in New Issue