[date_time] nanosec resolution compile problem
Hi,
i am trying to use date_time with nanosec resolution for the fractional seconds part. So i define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG in my projects using date_time. Now i get the compiler warning below. I found out that the problem in the said function is that in boost/date_time/date_duration.hpp the struct duration_traits_adapted defines the int_type as long and not as int_64t.
The warning is generated in the add_time_duration() funtion of the split_timedate_system class. So i imagine that this is a bigger issue, because if the durations get bigger than what a long can hold (what will happen fast with nanosec resolution) the problems will come.
Can this be resolved with an small fix to the duration_traits_adapted struct or have there to be more fixes?
Here the compiler warning (VS.net 2005 SP1)
boost\boost/date_time/time_system_split.hpp(189) : warning C4244: 'initializing' : conversion from '__int64' to 'long', possible loss of data
D:\_devel\schism_wc_x86\schism\projects\cmake\..\..\ext\inc\boost\boost/date_time/time_system_split.hpp(180) : while compiling class template member function 'boost::posix_time::simple_time_rep boost::date_time::split_timedate_system<config>::add_time_duration(const boost::posix_time::simple_time_rep &,boost::posix_time::time_duration)'
with
[
config=boost::posix_time::posix_time_system_config
]
D:\_devel\schism_wc_x86\schism\projects\cmake\..\..\ext\inc\boost\boost/date_time/time.hpp(52) : see reference to class template instantiation 'boost::date_time::split_timedate_system<config>' being compiled
with
[
config=boost::posix_time::posix_time_system_config
]
D:\_devel\schism_wc_x86\schism\projects\cmake\..\..\ext\inc\boost\boost/date_time/posix_time/ptime.hpp(32) : see reference to class template instantiation 'boost::date_time::base_time
Christopher Lux wrote: Sorry for the slow response...
Hi, i am trying to use date_time with nanosec resolution for the fractional seconds part. So i define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG in my projects using date_time. Now i get the compiler warning below. I found out that the problem in the said function is that in boost/date_time/date_duration.hpp the struct duration_traits_adapted defines the int_type as long and not as int_64t.
Right, it doesn't need to be 64 bits and you really shouldn't pay for that.
The warning is generated in the add_time_duration() funtion of the split_timedate_system class. So i imagine that this is a bigger issue, because if the durations get bigger than what a long can hold (what will happen fast with nanosec resolution) the problems will come.
Can this be resolved with an small fix to the duration_traits_adapted struct or have there to be more fixes?
Here the compiler warning (VS.net 2005 SP1)
boost\boost/date_time/time_system_split.hpp(189) : warning C4244: 'initializing' : conversion from '__int64' to 'long', possible loss of data
What version of boost are you using b/c AFAICT, int_type should be 64 bits if things are setup correctly. That is, you should be selecting this set of traits: //! traits struct for time_resolution_traits implementation type struct time_resolution_traits_adapted64_impl { typedef boost::int64_t int_type; which should give you 64 bits? But clearly, something else is going on... Jeff
Jeff Garland
Sorry for the slow response...
No Problem ;)
i am trying to use date_time with nanosec resolution for the fractional seconds part. So i define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG in my projects using date_time. Now i get the compiler warning below. I found out that the problem in the said function is that in boost/date_time/date_duration.hpp the struct duration_traits_adapted defines the int_type as long and not as int_64t.
Right, it doesn't need to be 64 bits and you really shouldn't pay for that.
I think the problem is, that in the posix_time the correct 64bit integer type is used and in the gregorion part only long is defined (boost/date_time/date_duration.hpp the struct duration_traits_adapted). Now in the time_system_split.hpp file the operations for adding and substracting time durations (posix_time) to dates is defined and this is generating the warning. In the substraction method a static_cast is exactly at the place where in the addition method the warning is generated. I do no know if there is a situation where this issue can make problems but i think it would not hurt to have the add and sub calculations done in the bigger value range to counter all possible problems.
What version of boost are you using b/c AFAICT, int_type should be 64 bits if things are setup correctly. That is, you should be selecting this set of traits:
I am using the 1.34 release.
//! traits struct for time_resolution_traits implementation type struct time_resolution_traits_adapted64_impl { typedef boost::int64_t int_type;
I use boost::posix_time::ptime and as far as i can see this is the relolution i have, but as i said the problem is that in the split_time calculations convertions are done to long which is defined in the duration traits of the date part of the lib. Now the question is if a simple cast is enough or does there have to be a correct calculation in the split time funktions. regards -chris -- Christopher Lux | | Bauhaus University Weimar | Faculty of Media - Virtual Reality Systems Group
participants (2)
-
Christopher Lux
-
Jeff Garland