为什么gdb8.2在Centos7阿里云上编译错误?

时间:2018-09-21 21:41:20

标签: c gcc gdb gnu

我在aliyun Centos7上获得了gcc8.2,但是当我获得gdb-8.2并使用时 。/配置 使 然后在ser-tcp.c中发生编译错误。这是错误信息:

ser-tcp.c:64:13: error: conflicting declaration ‘typedef int socklen_t’
 typedef int socklen_t;
         ^~~~~~~~~
In file included from build-gnulib/import/unistd.h:40,
             from ./gnulib/import/pathmax.h:42,
             from ./common/common-defs.h:84,
             from defs.h:28,
             from ser-tcp.c:20:
/usr/include/unistd.h:274:21: note: previous declaration as ‘typedef __socklen_t socklen_t’
 typedef __socklen_t socklen_t;
                 ^~~~~~~~~
ser-tcp.c: In function ‘int net_open(serial*, const char*)’:
ser-tcp.c:223:19: error: ‘FIONBIO’ was not declared in this scope
   ioctl (scb->fd, FIONBIO, &ioarg);
               ^~~~~~~
ser-tcp.c:223:3: error: ‘ioctl’ was not declared in this scope
   ioctl (scb->fd, FIONBIO, &ioarg);
   ^~~~~

对于gcc-compiler,首先我从yum默认安装了gcc-4.8.5,然后下载gcc-8.2并进行编译和替换。 这是我的gcc-8.2 -v信息:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-8.2.0/configure --enable-checking=release --enable- languages=c,c++ --disable-multilib
Thread model: posix
gcc version 8.2.0 (GCC) 

顺便说一句,这不是因为不包括标头,而是所需的标头在代码中被宏分割了。问题是为什么宏在编译时不正确。

1 个答案:

答案 0 :(得分:1)

  

In file included from build-gnulib/import/unistd.h:40,
  /usr/include/unistd.h:274:21: note: previous declaration as

您的编译器无论如何都是#includingbuild-gnulib/.../unistd.h的{​​{1}}。

/usr/lib/unistd.h很可能根本不属于这里。只有知道您build-gnulib与哪个GCC一起才能得到答案。