boost错误:变量“ timespec rqtp”具有初始化程序,但类型不完整

问题描述 投票:0回答:1

我正在尝试使用boost :: program_options并在编译时出现此错误:

$ g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 2015 Free Software Foundation, Inc.

...

/data/shared/ip_tools/include/boost/smart_ptr/detail/yield_k.hpp:143:25: error: variable ‘timespec rqtp’ has initializer but incomplete type
  143 |         struct timespec rqtp = { 0, 0 };
      |                         ^~~~
/data/shared/ip_tools/include/boost/smart_ptr/detail/yield_k.hpp:151:9: error: ‘nanosleep’ was not declared in this scope
  151 |         nanosleep( &rqtp, 0 );
      |         ^~~~~~~~~

我的(已编辑的)代码:

#include <boost/program_options.hpp>
int main(int argc, char* argv[]) {
  namespace po = boost::program_options;
  po::options_description cmd_opts{"Options"};
  po::options_description config_file_opts;
etc.

我的增强安装有问题吗?这似乎是一个图书馆问题...

c++ boost g++
1个回答
0
投票

这表示缺少包含。您应该可以通过在包含增强功能之前手动将其包含来解决它:

https://en.cppreference.com/w/c/chrono/timespec

#include <time.h>

也可能是缺少C11支持的编译器。为了比较,我使用的是GCC 10。

© www.soinside.com 2019 - 2024. All rights reserved.