Menu

Example tutorial_fmt_stream.cpp does not compile (MS Visual C++)

Help
2014-03-31
2014-03-31
  • Mario Knezović

    Mario Knezović - 2014-03-31

    Hi Andrey and others,

    I tried to get help for this on the boost list twice within a couple of months, but did not get any replies yet. Hopefully here. :-)

    I am trying to change date formatting exactly in the way as described in the tutorial, sub-section "Specialized formatters":

    http://www.boost.org/doc/libs/1_54_0/libs/log/doc/html/log/tutorial/formatters.html#log.tutorial.formatters.specialized_formatters
    (...or Boost 1.55.0)

    What I want to achieve is pretty simple, change month output from the default "Abbreviated month name" (%b):
    [2013-Jul-08 10:51:00.989235]
    to "Month name as a decimal 01 to 12" (%m):
    [2013-07-08 10:51:00.989235]

    (Basically like it is when no formatter is used, like in the "trivial" examples.)

    Unfortunately this does not compile, nor does the example from which the snipped is taken: "tutorial_fmt_stream.cpp".

    The interesting part in the example source is commented out by default. (But this was the case with other examples too.)

    The part I'm interested in is in line 60 (from Boost 1.54.0 or 1.55.0):

    expr::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S")

    The errors I get (Win7/8.1, 64-bit, both MS VC++ 2010 and 2013):

    error C2027: use of undefined type "boost::log::v2s_mt_nt5::expressions::aux::date_time_formatter_generator_traits\<T,CharT>" d:\boost\boost_1_54_0\boost\log\expressions\formatters\date_time.hpp 94

    error C3861: "parse": Identifier not found. d:\boost\boost_1_54_0\boost\log\expressions\formatters\date_time.hpp 94

    I hope somebody can help or point me in the right direction.

    Thank you!

    Mario

    EDIT: I just noticed the error message with VS2013 is a bit different:

    error C2027: use of undefined type 'boost::log::v2s_mt_nt5::expressions::aux::date_time_formatter_generator_traits\<boost::posix_time::ptime,char,void>'
    c:\boost\boost_1_55_0\boost\log\expressions\formatters\date_time.hpp 94

     

    Last edit: Mario Knezović 2014-03-31
  • Andrey Semashev

    Andrey Semashev - 2014-03-31

    Try adding

    #include <boost/log/support/date_time.hpp>
    

    to the example.

     
  • Mario Knezović

    Mario Knezović - 2014-03-31

    Magic! Now it works. Thanks a lot for the super fast reply!

     

Log in to post a comment.