Skip to content

Commit 0a7ace3

Browse files
committed
Merge branch 'change/remove-sys_dirent_h-include' into 'master'
change(newlib): prepare dirent.h to remove Closes IDF-10675 and LLVM-330 See merge request espressif/esp-idf!41608
2 parents 7c369ba + bc4a9ad commit 0a7ace3

File tree

8 files changed

+67
-87
lines changed

8 files changed

+67
-87
lines changed

components/newlib/platform_include/sys/dirent.h

Lines changed: 0 additions & 70 deletions
This file was deleted.

components/newlib/test_apps/newlib/main/test_misc.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212
#include <errno.h>
1313
#include <sys/param.h>
1414
#include <stdlib.h>
15-
#ifdef __clang__ // TODO LLVM-330
16-
#include <sys/dirent.h>
17-
#else
1815
#include <dirent.h>
19-
#endif
2016
#include "unity.h"
2117
#include "esp_heap_caps.h"
2218
#include "esp_vfs.h"

components/vfs/include/esp_vfs.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@
2121
#include <sys/time.h>
2222
#include <sys/termios.h>
2323
#include <sys/poll.h>
24-
#ifdef __clang__ // TODO LLVM-330
25-
#include <sys/dirent.h>
26-
#else
2724
#include <dirent.h>
28-
#endif
2925
#include <string.h>
3026
#include "sdkconfig.h"
3127

components/vfs/include/esp_vfs_ops.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
#include <sys/time.h>
2020
#include <sys/termios.h>
2121
#include <sys/poll.h>
22-
#ifdef __clang__ // TODO LLVM-330
23-
#include <sys/dirent.h>
24-
#else
2522
#include <dirent.h>
26-
#endif
2723
#include <string.h>
2824
#include "sdkconfig.h"
2925

components/vfs/test_apps/main/test_vfs_paths.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
#include <string.h>
1111
#include <errno.h>
1212
#include <sys/fcntl.h>
13-
#ifdef __clang__ // TODO LLVM-330
14-
#include <sys/dirent.h>
15-
#else
1613
#include <dirent.h>
17-
#endif
1814
#include "esp_vfs.h"
1915
#include "unity.h"
2016
#include "esp_log.h"

docs/en/migration-guides/release-6.x/6.0/toolchain.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,39 @@ Warn when an explicitly defaulted function is deleted by the compiler. That can
9393
C(const C&&) = default; /* Implicitly deleted. */
9494
};
9595
96+
``sys/dirent.h`` No Longer Includes Function Prototypes
97+
-------------------------------------------------------
98+
99+
Issue
100+
^^^^^^
101+
102+
Compilation errors may occur in code that previously worked with the old toolchain. For example:
103+
104+
.. code-block:: c
105+
106+
#include <sys/dirent.h>
107+
/* .... */
108+
DIR* dir = opendir("test_dir");
109+
/* .... */
110+
/**
111+
* Compile error:
112+
* test.c: In function 'test_opendir':
113+
* test.c:100:16: error: implicit declaration of function 'opendir' [-Werror=implicit-function-declaration]
114+
* 100 | DIR* dir = opendir(path);
115+
* | ^~~~~~~
116+
*/
117+
118+
Solution
119+
^^^^^^^^^
120+
121+
To resolve this issue, the correct header must be included. Refactor the code like this:
122+
123+
.. code-block:: c
124+
125+
#include <dirent.h>
126+
/* .... */
127+
DIR* dir = opendir("test_dir");
128+
96129
Picolibc
97130
--------
98131

docs/zh_CN/migration-guides/release-6.x/6.0/toolchain.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,39 @@ GCC 版本更新说明
9393
C(const C&&) = default; /* 被隐式删除 */
9494
};
9595
96+
``sys/dirent.h`` 不再包含一些函数原型
97+
-------------------------------------------------------
98+
99+
问题
100+
^^^^^^
101+
102+
使用旧工具链的代码可能会出现编译错误。例如:
103+
104+
.. code-block:: c
105+
106+
#include <sys/dirent.h>
107+
/* .... */
108+
DIR* dir = opendir("test_dir");
109+
/* .... */
110+
/**
111+
* Compile error:
112+
* test.c: In function 'test_opendir':
113+
* test.c:100:16: error: implicit declaration of function 'opendir' [-Werror=implicit-function-declaration]
114+
* 100 | DIR* dir = opendir(path);
115+
* | ^~~~~~~
116+
*/
117+
118+
解决方法
119+
^^^^^^^^^
120+
121+
包含正确的头文件即可解决此问题。请将代码重构如下:
122+
123+
.. code-block:: c
124+
125+
#include <dirent.h>
126+
/* .... */
127+
DIR* dir = opendir("test_dir");
128+
96129
Picolibc
97130
--------
98131

tools/idf_py_actions/hints.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@
433433
match_to_output: True
434434

435435
-
436-
re: "implicit declaration of function '(opendir|readdir|telldir|seekdir|rewinddir|closedir|readdir_r|scandir|alphasort)'"
436+
re: "implicit declaration of function '(opendir|readdir|telldir|seekdir|rewinddir|closedir|readdir_r|scandir|alphasort|dirfd|fdclosedir|fdopendir|scandirat|versionsort|posix_getdents)'"
437437
hint: "Please include <dirent.h> (not <sys/dirent.h>)"
438438

439439
-

0 commit comments

Comments
 (0)