Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译base/TimeZone.cc与base/tests/TimeZone_util.cc时报错,添加-Wno-conversion与-Wno-missing-field-initializers后编译成功 #701

Open
Eresh-tech opened this issue Dec 2, 2023 · 1 comment

Comments

@Eresh-tech
Copy link

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后编译成功

@chenxuanw
Copy link

1724328580634
我这样build成功

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants