【问题标题】:static declaration of ‘close’ follows non-static declaration static inline int close(int sock)“close”的静态声明遵循非静态声明 static inline int close(int sock)
【发布时间】:2019-03-14 22:43:16
【问题描述】:

我已经用 c 开发了大约 6 个月,我对这里发生的事情感到非常困惑。尝试包含 socket.h 头文件时出现此错误。

static inline int close(int sock)
{
    return zsock_close(sock);
}

这是它似乎有问题的方法?我从构建中取回了这个。

In file included from /home/jordan/zephyr/zephyr/include/posix/pthread.h:13:0,
                 from /home/jordan/thrift/src/c/zephyr/mbedtlstest/../../../../include/thrift/os.h:10,
                 from /home/jordan/thrift/src/c/zephyr/mbedtlstest/../../../../include/thrift/types.h:4,
                 from /home/jordan/thrift/src/c/zephyr/mbedtlstest/../../../../include/thrift/ssl/../transport.h:4,
                 from /home/jordan/thrift/src/c/zephyr/mbedtlstest/../../../../include/thrift/ssl/transport.h:4,
                 from /home/jordan/thrift/src/c/ssl/transport.c:1:
/home/jordan/zephyr/zephyr/include/posix/unistd.h:21:12: note: previous declaration of ‘close’ was here

【问题讨论】:

  • 你不能将你的函数命名为close。该名称已被占用。
  • 试试close(int sock) --> JD_close(int sock)

标签: c zephyr-rtos


【解决方案1】:

正如 user3386109 所说,close 是一个 C POSIX 库函数,用于关闭文件描述符。您可以在此处找到有关它的更多信息:-

https://linux.die.net/man/2/close

解决此问题的正确方法是将您的函数重命名为以前从未使用过的独特名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-10
    • 1970-01-01
    • 2018-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多