boost error: variable ‘timespec rqtp’ has initializer but incomplete type

Viewed 203

I'm trying to use boost::program_options and am getting this error at compile:

$ 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 );
      |         ^~~~~~~~~

My (redacted) code:

#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.

Is this something wrong with my boost install? This seems like a library issue...

1 Answers

It would indicate a missing include. You should be able to work around it by including it manually before including boost:

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

#include <time.h>

It could also be a compiler lacking C11 support. I'm on GCC 10, for comparison.

Related