muduo icon indicating copy to clipboard operation
muduo copied to clipboard

Build error

Open Gitspike opened this issue 6 months ago • 2 comments

[ 24%] Building CXX object muduo/net/CMakeFiles/muduo_net.dir/InetAddress.cc.o
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:50:35: error: expected primary-expression before ‘,’ token
   50 | static_assert(offsetof(sockaddr_in, sin_family) == 0, "sin_family offset 0");
      |                                   ^
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:50:37: error: ‘sin_family’ was not declared in this scope
   50 | static_assert(offsetof(sockaddr_in, sin_family) == 0, "sin_family offset 0");
      |                                     ^~~~~~~~~~
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:50:15: error: ‘offsetof’ was not declared in this scope
   50 | static_assert(offsetof(sockaddr_in, sin_family) == 0, "sin_family offset 0");
      |               ^~~~~~~~
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:16:1: note: ‘offsetof’ is defined in header ‘<cstddef>’; did you forget to ‘#include <cstddef>’?
   15 | #include <netdb.h>
  +++ |+#include <cstddef>
   16 | #include <netinet/in.h>
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:51:36: error: expected primary-expression before ‘,’ token
   51 | static_assert(offsetof(sockaddr_in6, sin6_family) == 0, "sin6_family offset 0");
      |                                    ^
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:51:38: error: ‘sin6_family’ was not declared in this scope
   51 | static_assert(offsetof(sockaddr_in6, sin6_family) == 0, "sin6_family offset 0");
      |                                      ^~~~~~~~~~~
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:51:15: error: ‘offsetof’ was not declared in this scope
   51 | static_assert(offsetof(sockaddr_in6, sin6_family) == 0, "sin6_family offset 0");
      |               ^~~~~~~~
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:51:15: note: ‘offsetof’ is defined in header ‘<cstddef>’; did you forget to ‘#include <cstddef>’?
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:52:35: error: expected primary-expression before ‘,’ token
   52 | static_assert(offsetof(sockaddr_in, sin_port) == 2, "sin_port offset 2");
      |                                   ^
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:52:37: error: ‘sin_port’ was not declared in this scope; did you mean ‘in_port_t’?
   52 | static_assert(offsetof(sockaddr_in, sin_port) == 2, "sin_port offset 2");
      |                                     ^~~~~~~~
      |                                     in_port_t
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:52:15: error: ‘offsetof’ was not declared in this scope
   52 | static_assert(offsetof(sockaddr_in, sin_port) == 2, "sin_port offset 2");
      |               ^~~~~~~~
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:52:15: note: ‘offsetof’ is defined in header ‘<cstddef>’; did you forget to ‘#include <cstddef>’?
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:53:36: error: expected primary-expression before ‘,’ token
   53 | static_assert(offsetof(sockaddr_in6, sin6_port) == 2, "sin6_port offset 2");
      |                                    ^
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:53:38: error: ‘sin6_port’ was not declared in this scope
   53 | static_assert(offsetof(sockaddr_in6, sin6_port) == 2, "sin6_port offset 2");
      |                                      ^~~~~~~~~
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:53:15: error: ‘offsetof’ was not declared in this scope
   53 | static_assert(offsetof(sockaddr_in6, sin6_port) == 2, "sin6_port offset 2");
      |               ^~~~~~~~
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:53:15: note: ‘offsetof’ is defined in header ‘<cstddef>’; did you forget to ‘#include <cstddef>’?
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc: In constructor ‘muduo::net::InetAddress::InetAddress(uint16_t, bool, bool)’:
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:57:37: error: expected primary-expression before ‘,’ token
   57 |   static_assert(offsetof(InetAddress, addr6_) == 0, "addr6_ offset 0");
      |                                     ^
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:57:17: error: ‘offsetof’ was not declared in this scope
   57 |   static_assert(offsetof(InetAddress, addr6_) == 0, "addr6_ offset 0");
      |                 ^~~~~~~~
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:57:17: note: ‘offsetof’ is defined in header ‘<cstddef>’; did you forget to ‘#include <cstddef>’?
/home/spike/projects/self/muduo/muduo/net/InetAddress.cc:58:37: error: expected primary-expression before ‘,’ token
   58 |   static_assert(offsetof(InetAddress, addr_) == 0, "addr_ offset 0");
      |                                     ^
make[2]: *** [muduo/net/CMakeFiles/muduo_net.dir/build.make:174: muduo/net/CMakeFiles/muduo_net.dir/InetAddress.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1765: muduo/net/CMakeFiles/muduo_net.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

环境: Ubuntu22.04

cmake 版本 3.28.1

gcc: gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)

boost版本 libboost1.74-dev:amd64

Gitspike avatar Aug 15 '24 07:08 Gitspike