#8696 closed Bugs (fixed)
chrono compilation error on Solaris/gcc
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.54.0 | Component: | chrono |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
The "timegm" function is not available on Solaris (Solaris 11) when using the gcc toolchain. It works fine for the sunpro toolchain. The "timegm" manual on regular linux says (man timegm):
"
For a portable version of timegm(), set the TZ environment variable to UTC, call mktime(3) and restore the value of TZ. Something like
#include <time.h> #include <stdlib.h>
time_t my_timegm(struct tm *tm) {
time_t ret; char *tz;
tz = getenv("TZ"); setenv("TZ", "", 1); tzset(); ret = mktime(tm); if (tz)
setenv("TZ", tz, 1);
else
unsetenv("TZ");
tzset(); return ret;
}
"
The Boost.Chrono has its own implementation available as the internal_timegm() function, however the implementation is used only in very limited cases (currently Windows but not Cygwin env.) selected by the BOOST_CHRONO_INTERNAL_TIMEGM macrodefinition. The proposed patch enables the internal_timegm() also for Solaris/gcc. The issue concerns chrono in version 2 (BOOST_CHRONO_VERSION=2).
The attached application reproduces the issue:
$ g++ chrono_io_test_solaris.cpp -lboost_system -DBOOST_CHRONO_VERSION=2 In file included from boost/chrono/chrono_io.hpp:26:0,
from chrono_io_test_solaris.cpp:1:
boost/chrono/io/time_point_io.hpp: In function 'std::basic_istream<_CharT, _Traits>& boost::chrono::operator>>(std::basic_istream<_CharT, _Traits>&, boost::chrono::time_point<boost::chrono::system_clock, Duration>&)': boost/chrono/io/time_point_io.hpp:1003:27: error: there are no arguments to 'timegm' that depend on a template parameter, so a declaration of 'timegm' must be available boost/chrono/io/time_point_io.hpp:1003:27: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) boost/chrono/io/time_point_io.hpp:1055:29: error: there are no arguments to 'timegm' that depend on a template parameter, so a declaration of 'timegm' must be available $
Attachments (2)
Change History (6)
by , 9 years ago
Attachment: | bug_8696.patch added |
---|
comment:1 by , 9 years ago
Milestone: | To Be Determined → Boost 1.54.0 |
---|---|
Status: | new → assigned |
Thanks for the patch.
comment:3 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:4 by , 9 years ago
The original ticket description claims that timegm is available when using the sunpro toolchain on Solaris 11. That claim is not correct, and even with this bug fix the code does not work with the sunpro toolchain. I filed new ticket 9918 for this problem.
patch