为什么clang编译器抱怨,尽管所有内容都呈现

发布于 2025-02-06 02:34:04 字数 1750 浏览 2 评论 0原文

我正在尝试通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文