chenshuo / muduo

Event-driven network library for multi-threaded Linux server in C++11
https://github.com/chenshuo/muduo
Other
14.88k stars 5.18k forks source link

[FIX] fix InetAddress compile, and use getaddrinfo instead of gethostbyname_r #709

Open Simonhancrew opened 5 months ago

Simonhancrew commented 5 months ago

@chenshuo

cpp17, compile issue occurs

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");

my gcc version

gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

And InetAddress::resolve use gethostbyname_r, maybe we should use getaddrinfo instead

ggandycong commented 5 months ago

刘德聪,已经收到你的邮件,请你放心 祝你生活愉快,笑口常开