error: multiple types in one declaration in header define declaration
error: multiple types in one declaration in header define declaration
Github
为了编译一个项目(萌芽),我必须先编译 libmemcached。在编译过程中,它会生成一个 config.h
文件,我认为它来自 config.ac
。但是,这 config.h
导致问题:
make all-am
make[1]: Entering directory `/home/tiina/clearwater/sprout/modules/libmemcached'
CXX libhashkit/libhashkit_libhashkit_la-aes.lo
In file included from ./libhashkit/common.h:40:0,
from libhashkit/aes.cc:38:
./config.h:632:20: error: multiple types in one declaration
#define off_t long int
^
./config.h:632:20: error: declaration does not declare anything [-fpermissive]
./config.h:658:17: error: multiple types in one declaration
#define ssize_t int
^
./config.h:658:17: error: declaration does not declare anything [-fpermissive]
./config.h:635:15: error: multiple types in one declaration
#define pid_t int
^
./config.h:635:15: error: declaration does not declare anything [-fpermissive]
make[1]: *** [libhashkit/libhashkit_libhashkit_la-aes.lo] Error 1
make[1]: Leaving directory `/home/tiina/clearwater/sprout/modules/libmemcached'
这是config.h:
628 /* Define to rpl_malloc if the replacement function should be used. */
629 #define malloc rpl_malloc
630
631 /* Define to `long int' if <sys/types.h> does not define. */
632 #define off_t long int
633
634 /* Define to `int' if <sys/types.h> does not define. */
635 #define pid_t int
636
637 /* Define to rpl_realloc if the replacement function should be used. */
638 #define realloc rpl_realloc
657 /* Define to `int' if <sys/types.h> does not define. */
658 #define ssize_t int
在Ubuntu中没有遇到这个问题:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
在CentOS下有这个问题:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
更新:
作为@n。 1.8e9-where's-my-share m.建议,我深入挖掘。
#include <stdio.h>
#define off_t long int
int main() {
int a = 1;
int b = a++;
return 10;
}
以上代码编译,g++ -E -P
结果OK1
然后我交换 include
和 define
声明:
#define off_t long int
#include <stdio.h>
以上代码无法编译,g++ -E -P
结果错误
然后我删除了define
decalration,再次编译,结果OK2.
diff OK1 ERROR
输出:
173c173
< typedef __off_t off_t;
---
> typedef __off_t long int;
diff OK1 OK2
输出为空(OK1和OK2相同)。
然后我发布了 VIM 标记 off_t
与 long
或 int
相同的颜色。也许 off_t
是保留关键字?然后我将 off_t
更改为 offt
:
#define offt long int
#include <stdio.h>
它再次编译。
生成config.h
的配置脚本有问题。
631 /* Define to `long int' if <sys/types.h> does not define. */
632 #define off_t long int
如果 off_t
没有在您的系统上的任何地方定义,这会很好。但它是由系统头文件定义和使用的,很可能是这样的:
typedef long int __off_t;
typedef __off_t off_t;
#define
破坏了这些定义,使它们在语法上无效。
解决此问题的最简单方法是从 config.h
中手动删除有问题的 #define
,并确保包含 sys/types.h
。
Github
为了编译一个项目(萌芽),我必须先编译 libmemcached。在编译过程中,它会生成一个 config.h
文件,我认为它来自 config.ac
。但是,这 config.h
导致问题:
make all-am
make[1]: Entering directory `/home/tiina/clearwater/sprout/modules/libmemcached'
CXX libhashkit/libhashkit_libhashkit_la-aes.lo
In file included from ./libhashkit/common.h:40:0,
from libhashkit/aes.cc:38:
./config.h:632:20: error: multiple types in one declaration
#define off_t long int
^
./config.h:632:20: error: declaration does not declare anything [-fpermissive]
./config.h:658:17: error: multiple types in one declaration
#define ssize_t int
^
./config.h:658:17: error: declaration does not declare anything [-fpermissive]
./config.h:635:15: error: multiple types in one declaration
#define pid_t int
^
./config.h:635:15: error: declaration does not declare anything [-fpermissive]
make[1]: *** [libhashkit/libhashkit_libhashkit_la-aes.lo] Error 1
make[1]: Leaving directory `/home/tiina/clearwater/sprout/modules/libmemcached'
这是config.h:
628 /* Define to rpl_malloc if the replacement function should be used. */
629 #define malloc rpl_malloc
630
631 /* Define to `long int' if <sys/types.h> does not define. */
632 #define off_t long int
633
634 /* Define to `int' if <sys/types.h> does not define. */
635 #define pid_t int
636
637 /* Define to rpl_realloc if the replacement function should be used. */
638 #define realloc rpl_realloc
657 /* Define to `int' if <sys/types.h> does not define. */
658 #define ssize_t int
在Ubuntu中没有遇到这个问题:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
在CentOS下有这个问题:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
更新: 作为@n。 1.8e9-where's-my-share m.建议,我深入挖掘。
#include <stdio.h>
#define off_t long int
int main() {
int a = 1;
int b = a++;
return 10;
}
以上代码编译,g++ -E -P
结果OK1
然后我交换 include
和 define
声明:
#define off_t long int
#include <stdio.h>
以上代码无法编译,g++ -E -P
结果错误
然后我删除了define
decalration,再次编译,结果OK2.
diff OK1 ERROR
输出:
173c173
< typedef __off_t off_t;
---
> typedef __off_t long int;
diff OK1 OK2
输出为空(OK1和OK2相同)。
然后我发布了 VIM 标记 off_t
与 long
或 int
相同的颜色。也许 off_t
是保留关键字?然后我将 off_t
更改为 offt
:
#define offt long int
#include <stdio.h>
它再次编译。
生成config.h
的配置脚本有问题。
631 /* Define to `long int' if <sys/types.h> does not define. */
632 #define off_t long int
如果 off_t
没有在您的系统上的任何地方定义,这会很好。但它是由系统头文件定义和使用的,很可能是这样的:
typedef long int __off_t;
typedef __off_t off_t;
#define
破坏了这些定义,使它们在语法上无效。
解决此问题的最简单方法是从 config.h
中手动删除有问题的 #define
,并确保包含 sys/types.h
。