C '的冲突类型;strtold';

C '的冲突类型;strtold';,c,centos,C,Centos,我运行MUD(用C编码),并一直在将它们迁移到新服务器。我在这两个服务器上运行了相同版本的gcc(和相同的Makefile),但在新服务器上编译时出现错误: /usr/bin/gcc34 -c -g -g3 -Wall -DREQUESTS -DSMAUG14 -DTIMEFORMAT -DREGEX build.c build.c:33: error: conflicting types for 'strtold' /usr/include/stdlib.h:178: error: p

我运行MUD(用C编码),并一直在将它们迁移到新服务器。我在这两个服务器上运行了相同版本的gcc(和相同的Makefile),但在新服务器上编译时出现错误:

/usr/bin/gcc34 -c -g -g3 -Wall    -DREQUESTS -DSMAUG14  -DTIMEFORMAT -DREGEX build.c
build.c:33: error: conflicting types for 'strtold'
/usr/include/stdlib.h:178: error: previous declaration of 'strtold' was here
该行:

long double     strtold         args( ( const char *string, const char **endstring) );
新服务器上的stdlib.h行:

extern long double strtold (__const char *__restrict __nptr,
                        char **__restrict __endptr)
4525.   extern long double strtold (__const char *__restrict __nptr,
4526.          char **__restrict __endptr)
4527.        __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;
在旧服务器上同一目录下的stdlib.h上,同一行:

extern long double strtold (__const char *__restrict __nptr,
                        char **__restrict __endptr)
但是旧服务器没有收到此编译错误。旧服务器gcc:

[user@old src]# /usr/bin/gcc34 -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,f77 --disable-libgcj --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-4.1)
[user@new src]$ /usr/bin/gcc34 -v
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,f77 --disable-libgcj --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-19.el6)
新服务器gcc:

[user@old src]# /usr/bin/gcc34 -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,f77 --disable-libgcj --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-4.1)
[user@new src]$ /usr/bin/gcc34 -v
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,f77 --disable-libgcj --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-19.el6)
请注意,
args
是:

 #define args( list )                    ( )
我错过了什么?如果代码、gcc版本和Makefile相同,那么指向不同库的可能是什么

更新:运行
gcc-E
开始揭示一些旧服务器:

3946.   extern long double __strtold_internal (__const char *__restrict __nptr,
3947.              char **__restrict __endptr,
3948.              int __group)
3949.        __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;
新服务器:

extern long double strtold (__const char *__restrict __nptr,
                        char **__restrict __endptr)
4525.   extern long double strtold (__const char *__restrict __nptr,
4526.          char **__restrict __endptr)
4527.        __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;
显然,stdlib.h是不同的。尽管我有相同的gcc版本,但有没有办法在新服务器上复制旧库以确保迁移顺利

在库中的
strtold
extern上方,我也注意到了这一点:

#ifdef  __USE_ISOC99
__BEGIN_NAMESPACE_C99

相关的

您的签名不匹配。您的定义有
const char*,const char**
但stdlib.h有
const char*,char**
。注意,它们的第二个参数不是常数。解决这个问题,它可能会起作用

为什么在我说不出来之前没有出错。您正在13年的操作系统上使用12年的编译器

假设您自己的strtold实现不存在,那么这可能是因为它不存在。通常,您需要运行一个配置程序,该程序探测系统的功能,并生成一个具有定义的头文件,如
#define HAS_STRTOLD
。然后您可以使用
#ifndef HAS_STRTOLD
包装您的兼容版本


您的代码可能有类似的内容。它在旧机器上找到了strtold,而在新机器上没有。新机器上的探针可能已损坏。

您的签名不匹配。您的定义有
const char*,const char**
但stdlib.h有
const char*,char**
。注意,它们的第二个参数不是常数。解决这个问题,它可能会起作用

为什么在我说不出来之前没有出错。您正在13年的操作系统上使用12年的编译器

假设您自己的strtold实现不存在,那么这可能是因为它不存在。通常,您需要运行一个配置程序,该程序探测系统的功能,并生成一个具有定义的头文件,如
#define HAS_STRTOLD
。然后,您可以使用
ාifndef HAS_ustrord
,包装兼容版本



您的代码可能有类似的内容。它在旧机器上找到了strtold,而在新机器上没有。新机器上的探针可能已损坏。

您能告诉我们完整的定义吗?什么是
args
?大概是在
strtold
不存在的情况下。您应该使用配置程序来确定哪些函数存在和不存在,并在此基础上构建头文件。@Schwern在中编辑了这些函数。两台服务器上的头文件和所有代码文件完全相同。
strtold
由C标准库定义。为什么
build.c
要重新定义它?@KeithThompson我不是这个MUD的原始开发者,我没有这个答案。我更多的是做迁移的许多MUD的系统管理员。但是MUD作为一个注释已经很古老了(1994年用于这个代码库)。@KeithThompson软件为了可移植性的目的定义函数是很常见的。尤其是旧软件,它必须与许多标准遵从性有问题的编译器一起工作。例如,虽然它很聪明,你能给我们完整的定义吗?什么是
args
?大概是在
strtold
不存在的情况下。您应该使用配置程序来确定哪些函数存在和不存在,并在此基础上构建头文件。@Schwern在中编辑了这些函数。两台服务器上的头文件和所有代码文件完全相同。
strtold
由C标准库定义。为什么
build.c
要重新定义它?@KeithThompson我不是这个MUD的原始开发者,我没有这个答案。我更多的是做迁移的许多MUD的系统管理员。但是MUD作为一个注释已经很古老了(1994年用于这个代码库)。@KeithThompson软件为了可移植性的目的定义函数是很常见的。尤其是旧软件,它必须与许多标准遵从性有问题的编译器一起工作。例如,虽然它非常聪明。我确实理解错误发生的原因,但我正在尝试确定这些错误现在出现的原因。从技术上讲,我是这里的主机,而不是开发人员,我不确定我是否能够拥有代码更改的所有权,特别是当托管了几十个可能会遇到类似情况的MUD时。@Zeno告诉他们他们的代码有一个bug,他们需要修复它。我添加了一个可能发生这种情况的原因。我正计划这样做,但这些类型的未知场景将使迁移服务器成为MUD主机的一大难题。我在任何地方都看不到这种泥浆的任何HAS\u STRTOLD。@Zeno它可能不会被称为
HAS\u STRTOLD
。我们需要了解build.c的整个上下文以进一步提供帮助。迁移旧的C代码可能会有问题,我表示哀悼。更新的问题带有gcc-E结果,显示了一些关于发生了什么的细节。我确实理解为什么会发生错误,但我正在尝试确定为什么现在会出现这些错误。从技术上讲,我是这里的主机,而不是开发人员,我不确定我是否能够拥有代码更改的所有权,特别是当托管了几十个可能会遇到类似情况的MUD时。@Zeno告诉他们他们的代码有一个bug,他们需要修复它。我添加了一个可能发生这种情况的原因。我正计划这样做,但这些类型的未知场景将使迁移服务器成为MUD主机的一大难题。我不知道