<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97033>97033</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] misc-include-cleaner false positive for <net/if.h> header
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
abdelmaged
</td>
</tr>
</table>
<pre>
clang-tidy version:
```
LLVM (http://llvm.org/):
LLVM version 18.1.6
Optimized build.
```
Consider following C file `main.c`
```C
#include <net/if.h>
#include <stdio.h>
int main(int argc, char **argv) {
printf("%d\n", IFF_LOOPBACK);
return 0;
}
```
Running check `misc-include-cleaner` like in command:
```bash
clang-tidy --checks=misc-include-cleaner main.c --
```
Results in the following false warning:
```
1 warning generated.
main.c:1:1: warning: included header if.h is not used directly [misc-include-cleaner]
1 | #include <net/if.h>
| ^~~~~~~~~~~~~~~~~~~
2 | #include <stdio.h>
```
When applying suggestion then recompile using `clang main.c`, we will get following compilation error:
```
main.c:5:18: error: use of undeclared identifier 'IFF_LOOPBACK'
5 | printf("%d\n", IFF_LOOPBACK);
| ^
1 error generated.
```
`net/if.h` is from glibc library, and we may see its contents in:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/gnu/net/if.h;hb=e84eabb3871c9b39e59323bf3f6b98c2ca9d1cd0
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVc-P6yYQ_mvIZZQIg38efEjiF6nqVlu9Q3usMIxt-jCOAO8qPfRvr3CcTZ42r5Vq7ToGZgbm-74ZhPe6t4g1yQ4kazZiDsPkatEqNKPoUW3aSV1qaYTtt0GrC7yh83qyhO8JbQjdk5yuf8vw5eW3X4CwcgjhHG3YibCTMW_jbnL9Mqo-XAEW6zUiJOUu2eXr0us56FH_hQraWRu1e7rZ9X2crNcKHXSTMdO7tj0codMGgeR0FNru5N3jFuC4jhnXVppZ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