stddef.h:错误:重复“无符号”;

发布于 2024-12-26 18:36:21 字数 1408 浏览 1 评论 0原文

我正在 Windows 7 x64 SUA/Interix 的 64 位 GCC 编译器上编译 grep

它在 stddef.h 中的标记行上卡住了:

#ifndef _SIZE_T_DEFINED
#if defined (lp64) || defined(_WIN64)
#ifdef lp64
typedef unsigned long   size_t;                    //    <------ error
#else /* lp64 */
typedef unsigned __int64        size_t;
#endif /* lp64 */
#else /* (defined(lp64) || defined(_WIN64)) */
typedef unsigned int  size_t;
#endif /* (defined(lp64) || defined(_WIN64)) */
#define _SIZE_T_DEFINED
#define _SIZE_T
#endif /* _SIZE_T_DEFINED */

make 的输出是:

make  all-recursive
Making all in intl
gcc -c -DLOCALEDIR=\"/usr/local/share/locale\" -DLOCALE_ALIAS_PATH=\"/usr/local/share/locale\"  -DLIBDIR=\"/usr/local/lib\" -DIN_LIBINTL -DHAVE_CONFIG_H -I.. -I. -I../../intl -D_ALL_SOURCE -D_REENTRANT -I/usr/local/include -I/usr/local/include -D_ALL_SOURCE -D_REENTRANT  ../../intl/intl-compat.c

In file included from ../../intl/gettextP.h:23:0,
                 from ../../intl/intl-compat.c:25:
/usr/include/stddef.h:50:23: error: duplicate 'unsigned'
*** Error code 1

Stop in /tmp/grep-2.5.4-src/build/intl.
*** Error code 1

Stop in /tmp/grep-2.5.4-src/build (line 329 of Makefile).
*** Error code 1

Stop in /tmp/grep-2.5.4-src/build (line 244 of Makefile).

我不明白原因是什么......它已经令人困惑了 long 在 GCC 中被当作 64 位使用,但错误更令人困惑!有想法吗?

I'm compiling grep on the 64-bit GCC compiler for Windows 7 x64 SUA/Interix.

It chokes on the marked line in stddef.h:

#ifndef _SIZE_T_DEFINED
#if defined (lp64) || defined(_WIN64)
#ifdef lp64
typedef unsigned long   size_t;                    //    <------ error
#else /* lp64 */
typedef unsigned __int64        size_t;
#endif /* lp64 */
#else /* (defined(lp64) || defined(_WIN64)) */
typedef unsigned int  size_t;
#endif /* (defined(lp64) || defined(_WIN64)) */
#define _SIZE_T_DEFINED
#define _SIZE_T
#endif /* _SIZE_T_DEFINED */

The output for make is:

make  all-recursive
Making all in intl
gcc -c -DLOCALEDIR=\"/usr/local/share/locale\" -DLOCALE_ALIAS_PATH=\"/usr/local/share/locale\"  -DLIBDIR=\"/usr/local/lib\" -DIN_LIBINTL -DHAVE_CONFIG_H -I.. -I. -I../../intl -D_ALL_SOURCE -D_REENTRANT -I/usr/local/include -I/usr/local/include -D_ALL_SOURCE -D_REENTRANT  ../../intl/intl-compat.c

In file included from ../../intl/gettextP.h:23:0,
                 from ../../intl/intl-compat.c:25:
/usr/include/stddef.h:50:23: error: duplicate 'unsigned'
*** Error code 1

Stop in /tmp/grep-2.5.4-src/build/intl.
*** Error code 1

Stop in /tmp/grep-2.5.4-src/build (line 329 of Makefile).
*** Error code 1

Stop in /tmp/grep-2.5.4-src/build (line 244 of Makefile).

I don't understand what the cause is... it's already confusing that long is being used as though it's 64-bit in GCC, but the error is even more confusing! Ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一片旧的回忆 2025-01-02 18:36:21

在你的代码中的某个地方,有人可能做了:

#define size_t unsigned long

或者类似的事情,但在他们这样做时没有定义_SIZE_T_DEFINED。然后他们的代码 #includes stddef.h 通过错误消息中列出的路径。这使得你的错误行看起来像:

typedef unsigned long unsigned long;

对于编译器,这是行不通的!

Somewhere in your code, somone probably did:

#define size_t unsigned long

Or something along those lines, without having defined _SIZE_T_DEFINED when they did it. Then their code #includes stddef.h via the path listed in your error message. That makes your error line look like:

typedef unsigned long unsigned long;

To the compiler, which is not going to work!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文