Event-driven network library for multi-threaded Linux server in C++11
14.64k
stars
5.14k
forks
source link
编译base/TimeZone.cc与base/tests/TimeZone_util.cc时报错,添加-Wno-conversion与-Wno-missing-field-initializers后编译成功 #701
Open
Eresh-tech opened 9 months ago
Linux distro and version? x86 or ARM? 32-bit or 64-bit?
Linux version 3.10.0-1160.el7.x86_64
Branch (cpp98/cpp11/cpp17) and version of muduo?
cpp11 v2.0.2
Version of cmake, gcc and boost? (If not from distro.)
cmake version 2.8.12.2 gcc: 首先使用gcc-4.8.5-44,首次编译失败后切换至11.2.1,以下报错信息均在11.2.1下出现 boost: 1.53.0-28
报错信息:
[ 0%] Building CXX object muduo/base/CMakeFiles/muduo_base.dir/TimeZone.cc.o muduo/muduo/base/TimeZone.cc: 在函数‘bool muduo::detail::readDataBlock(muduo::detail::File&, muduo::TimeZone::Data*, bool)’中: muduo/muduo/base/TimeZone.cc:171:36: 错误:‘int’转换自‘long unsigned int’时可能改变值 [-Werror=conversion] const int time_size = v1 ? sizeof(int32_t) : sizeof(int64_t); ^ muduo/muduo/base/TimeZone.cc:171:54: 错误:‘int’转换自‘long unsigned int’时可能改变值 [-Werror=conversion] const int time_size = v1 ? sizeof(int32_t) : sizeof(int64_t); ^ cc1plus: all warnings being treated as errors make[2]: *** [muduo/base/CMakeFiles/muduo_base.dir/build.make:381:muduo/base/CMakeFiles/muduo_base.dir/TimeZone.cc.o] 错误 1
添加-Wno-conversion后报错信息如下: muduo/muduo/base/tests/TimeZone_util.cc: 在函数‘int main(int, char**)’中: muduo/muduo/base/tests/TimeZone_util.cc:47:24: 错误:成员‘tm::tm_sec’缺少初始值设定 [-Werror=missing-field-initializers] struct tm tm = { }; ^ muduo/muduo/base/tests/TimeZone_util.cc:47:24: 错误:成员‘tm::tm_min’缺少初始值设定 [-Werror=missing-field-initializers] muduo/muduo/base/tests/TimeZone_util.cc:47:24: 错误:成员‘tm::tm_hour’缺少初始值设定 [-Werror=missing-field-initializers] muduo/muduo/base/tests/TimeZone_util.cc:47:24: 错误:成员‘tm::tm_mday’缺少初始值设定 [-Werror=missing-field-initializers] muduo/muduo/base/tests/TimeZone_util.cc:47:24: 错误:成员‘tm::tm_mon’缺少初始值设定 [-Werror=missing-field-initializers] muduo/muduo/base/tests/TimeZone_util.cc:47:24: 错误:成员‘tm::tm_year’缺少初始值设定 [-Werror=missing-field-initializers] muduo/muduo/base/tests/TimeZone_util.cc:47:24: 错误:成员‘tm::tm_wday’缺少初始值设定 [-Werror=missing-field-initializers] muduo/muduo/base/tests/TimeZone_util.cc:47:24: 错误:成员‘tm::tm_yday’缺少初始值设定 [-Werror=missing-field-initializers] muduo/muduo/base/tests/TimeZone_util.cc:47:24: 错误:成员‘tm::tm_isdst’缺少初始值设定 [-Werror=missing-field-initializers] muduo/muduo/base/tests/TimeZone_util.cc:47:24: 错误:成员‘tm::tm_gmtoff’缺少初始值设定 [-Werror=missing-field-initializers] muduo/muduo/base/tests/TimeZone_util.cc:47:24: 错误:成员‘tm::tm_zone’缺少初始值设定 [-Werror=missing-field-initializers] cc1plus: all warnings being treated as errors
我尝试修改muduo/base/CMakeLists.txt, 添加-Wno-conversion与-Wno-missing-field-initializers后编译成功