Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable nanoseconds in boost::posix_time?

Tags:

c++

boost

I want to use nanoseconds type define in boost::posix_time but it appears that this type is not defined. I looked in the implementation and it looks like the type definition is protected by

#if defined(BOOST_DATE_TIME_HAS_NANOSECONDS)

so I added to my code

# define BOOST_DATE_TIME_HAS_NANOSECONDS

but I keep getting the same compilation error. I in some pages on the web I saw that I might need to rebuild my boost library which is perfectly fine with me but I didn't see any related flags in bootstrap.sh or b2 and even if that was the problem I would expect this problem to appear during linkage not compilation. Any ideas what is the problem? Thanks in advance.

like image 206
e271p314 Avatar asked Oct 18 '25 14:10

e271p314


1 Answers

The documentation says:

Introduction

Defines a non-adjusted time system with nano-second/micro-second resolution and stable calculation properties. The nano-second resolution option uses 96 bits of underlying storage for each ptime while the micro-second resolution uses 64 bits per ptime (see Build Options for details). This time system uses the Gregorian calendar to implement the date portion of the time representation.

And the build options page says:

To use the alternate resolution (96 bit nanosecond) the variable BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG must be defined in the library users project files (ie Makefile, Jamfile, etc).

Please read the documentation.

like image 168
Lightness Races in Orbit Avatar answered Oct 21 '25 02:10

Lightness Races in Orbit