-1

I have get gcc8.2 on aliyun Centos7, but when I get gdb-8.2 and use ./configure make then it occur compile error in ser-tcp.c. Here are error infos:

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);
   ^~~~~

As for gcc-compiler, first I install a gcc-4.8.5 by default from yum.Then download gcc-8.2 and compile and replace. Here are my gcc-8.2 -v infos:

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) 

By the way, it's not because of not including header, needed header was divided by Macro in the code.The question is why the macro not right in compiling.

P二零
  • 3
  • 6
  • Possible duplicate of [porting ioctl() calls from unix to linux, error with FIONBIO](https://stackoverflow.com/questions/9609781/porting-ioctl-calls-from-unix-to-linux-error-with-fionbio) – Martin Zeitler Sep 22 '18 at 19:47

1 Answers1

1

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

Somehow your compiler is #including both build-gnulib/.../unistd.h and /usr/lib/unistd.h.

The build-gnulib most likely doesn't belong here at all. How it got here can only be answered by knowing which GCC you ./configured with.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • Very very thanks for your answer! I have add gcc ./confiugre infos above. According to your answer I guess there may be more incorrect including files in that host? Should I reset this system? Or by other way I can make the gdb succ, such as delete build-gnulib ? – P二零 Sep 22 '18 at 04:31