e271p314
e271p314

Reputation: 4039

How to enable nanoseconds in boost::posix_time?

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.

Upvotes: 4

Views: 4726

Answers (1)

Lightness Races in Orbit
Lightness Races in Orbit

Reputation: 385385

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.

Upvotes: 7

Related Questions