为什么clang编译器抱怨,尽管所有内容都呈现
我正在尝试通过 xdp教程以及与样本编译有问题。为什么Clang抱怨已经完成了其中的包含?
示例:
common_params.c:105:4: warning: incompatible implicit declaration of built-in function ‘strncpy’
common_params.c:105:4: note: include ‘<string.h>’ or provide a declaration of ‘strncpy’
common_params.c:110:6: error: ‘errno’ undeclared (first use in this function)
110 | errno, strerror(errno));
| ^~~~~
common_params.c:15:1: note: ‘errno’ is defined in header ‘<errno.h>’; did you forget to ‘#include <errno.h>’?
14 | #include "common_params.h"
+++ |+#include <errno.h>
cheching common_params.c鞋子已经有字符串。h和errno.h包括:
# head ../common/common_params.c
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <getopt.h>
#include <errno.h>
#include <stdio.h>
框中显示文件:
# ls -l /usr/include/errno.h
-rw-r--r-- 1 root root 23 Jun 6 18:36 /usr/include/errno.h
# ls -l /usr/include/string.h
-rw-r--r-- 1 root root 238 Jun 6 18:36 /usr/include/string.h
# cat /usr/include/errno.h
#include <asm/errno.h>
# cat /usr/include/asm/errno.h
#include <asm-generic/errno.h>
# head /usr/include/asm-generic/errno.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _ASM_GENERIC_ERRNO_H
#define _ASM_GENERIC_ERRNO_H
#include <asm-generic/errno-base.h>
#define EDEADLK 35 /* Resource deadlock would occur */
#define ENAMETOOLONG 36 /* File name too long */
#define ENOLCK 37 /* No record locks available */
I'm trying to work through XDP tutorial and having issue with samples compilation. Why clang complains regarding includes that are already done?
Example:
common_params.c:105:4: warning: incompatible implicit declaration of built-in function ‘strncpy’
common_params.c:105:4: note: include ‘<string.h>’ or provide a declaration of ‘strncpy’
common_params.c:110:6: error: ‘errno’ undeclared (first use in this function)
110 | errno, strerror(errno));
| ^~~~~
common_params.c:15:1: note: ‘errno’ is defined in header ‘<errno.h>’; did you forget to ‘#include <errno.h>’?
14 | #include "common_params.h"
+++ |+#include <errno.h>
Cheching common_params.c shoes it already have string.h and errno.h included:
# head ../common/common_params.c
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <getopt.h>
#include <errno.h>
#include <stdio.h>
Files are presented in the box:
# ls -l /usr/include/errno.h
-rw-r--r-- 1 root root 23 Jun 6 18:36 /usr/include/errno.h
# ls -l /usr/include/string.h
-rw-r--r-- 1 root root 238 Jun 6 18:36 /usr/include/string.h
# cat /usr/include/errno.h
#include <asm/errno.h>
# cat /usr/include/asm/errno.h
#include <asm-generic/errno.h>
# head /usr/include/asm-generic/errno.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _ASM_GENERIC_ERRNO_H
#define _ASM_GENERIC_ERRNO_H
#include <asm-generic/errno-base.h>
#define EDEADLK 35 /* Resource deadlock would occur */
#define ENAMETOOLONG 36 /* File name too long */
#define ENOLCK 37 /* No record locks available */
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论