date_time formatting compilation error
I'm trying to convert a gregorian::date to a string, as shown in the
following code:
// Build: cl /EHsc /I \CVS\boost dt.cpp
#include <iostream>
#include
On Sun, 14 Mar 2004 12:27:55 -0000, Keith MacDonald wrote
I'm trying to convert a gregorian::date to a string, as shown in the following code:
// Build: cl /EHsc /I \CVS\boost dt.cpp #include <iostream> #include
int main() { boost::gregorian::date today(2004, boost::gregorian::Mar, 14); std::cout << today << std::endl; return 0; }
This definately should work. What happens if you do std::cout << to_simple_string(today) << std::endl; or std::wcout << to_simple_wstring(today) << std::endl;
When I compile it with Visual C++ 7.1, using Boost from CVS head,
Are you positive about this? Changes to support wide streaming went in a couple weeks back. Seems like maybe you don't have all of that change.
I get the following error:
\CVS\boost\boost\lexical_cast.hpp(150) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'boost::date_time::date_formatter
::string_type' (or there is no acceptable conversion) with [ date_type=boost::gregorian::date, format_type=boost::date_time::simple_format, charT=wchar_t ] The same thing happens when using to_simple_string and to_simple_string_type<char>, rather than operator<<. I actually want the result as a basic_string
, but all variations produce this same error. What am I doing wrong?
I really don't know. Can you try running the regression tests in your environment? In particular I'm interested in libs/date_time/test/gregorian/testgreg_wstream.cpp Anyway, judging from the regression tests this should be working for you... Jeff
hi list can any one send me REDHAT rpm of boost jam. thanks
Hi
can any one send me REDHAT rpm of boost jam.
What's wrong with the version here: http://prdownloads.sourceforge.net/boost/boost-jam-3.1.9-1.i386.rpm?download ? Regards Paul Paul Grenyer Email: paul@paulgrenyer.co.uk Web: http://www.paulgrenyer.co.uk Have you met Aeryn: http://www.paulgrenyer.co.uk/aeryn/? Version 0.3.0 beta now ready for download
Thanks for your response.
I get the same results whatever I try, including with testgreg_wstream.cpp.
The only way I've been able to get my code working is to define
BOOST_DATE_TIME_NO_WSTRING_CONVERSIONS, and then convert to wchar_t myself.
I'm pretty sure my CVS files are up to date, but here's a directory listing
(in dd/mm/yyyy format), just in case:
18/02/2004 17:49 5,731 formatters.hpp
15/02/2004 16:17 2,845 formatters_limited.hpp
18/02/2004 17:49 1,006 gregorian.hpp
02/12/2003 15:14 3,107 gregorian_types.hpp
02/12/2003 15:14 1,572 greg_calendar.hpp
12/01/2004 16:42 3,824 greg_date.hpp
02/12/2003 15:14 1,826 greg_day.hpp
02/12/2003 15:14 1,078 greg_day_of_year.hpp
02/12/2003 15:14 922 greg_duration.hpp
01/03/2004 16:58 8,288 greg_facet.hpp
18/02/2004 17:49 2,911 greg_month.hpp
18/02/2004 17:49 1,897 greg_weekday.hpp
02/12/2003 15:14 1,648 greg_year.hpp
02/12/2003 15:14 904 greg_ymd.hpp
01/03/2004 16:58 3,195 parsers.hpp
- Keith MacDonald
"Jeff Garland"
On Sun, 14 Mar 2004 12:27:55 -0000, Keith MacDonald wrote
I'm trying to convert a gregorian::date to a string, as shown in the following code:
// Build: cl /EHsc /I \CVS\boost dt.cpp #include <iostream> #include
int main() { boost::gregorian::date today(2004, boost::gregorian::Mar, 14); std::cout << today << std::endl; return 0; }
This definately should work. What happens if you do std::cout << to_simple_string(today) << std::endl; or std::wcout << to_simple_wstring(today) << std::endl;
When I compile it with Visual C++ 7.1, using Boost from CVS head,
Are you positive about this? Changes to support wide streaming went in a couple weeks back. Seems like maybe you don't have all of that change.
I get the following error:
\CVS\boost\boost\lexical_cast.hpp(150) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'boost::date_time::date_formatter
::string_type' (or there is no acceptable conversion) with [ date_type=boost::gregorian::date, format_type=boost::date_time::simple_format, charT=wchar_t ] The same thing happens when using to_simple_string and to_simple_string_type<char>, rather than operator<<. I actually want the result as a basic_string
, but all variations produce this same error. What am I doing wrong? I really don't know. Can you try running the regression tests in your environment? In particular I'm interested in
libs/date_time/test/gregorian/testgreg_wstream.cpp
Anyway, judging from the regression tests this should be working for you...
Jeff
On Sun, 14 Mar 2004 16:07:41 -0000, Keith MacDonald wrote
Thanks for your response.
I get the same results whatever I try, including with testgreg_wstream.cpp. The only way I've been able to get my code working is to define BOOST_DATE_TIME_NO_WSTRING_CONVERSIONS, and then convert to wchar_t myself.
I'll check the CVS dates in a bit, but this leads me to believe you aren't actually using VC7.1? Is that somehow possible? The only other conclusion would be that the regression tests are somehow getting NO_WSTRING conversions set when they are run... Jeff
I've definitely only got VC7.1 on my PC, so that's not the issue. As to the
regression tests, I was not familiar with how to build and run them, so I
simply tried to compile testgreg_wstream.cpp on its own, using "cl /EHsc /I
\CVS\boost". As it failed to compile, there was no question of getting
NO_WSTRING conversions.
Having just read up on how to run the regression tests, I've successfully
built and run those for date_time, so there must be something simple wrong
with my compiler options. What else do I need, apart from "cl /EHsc /I
\CVS\boost" -which is sufficient for the regex library?
Thanks,
Keith MacDonald
"Jeff Garland"
On Sun, 14 Mar 2004 16:07:41 -0000, Keith MacDonald wrote
Thanks for your response.
I get the same results whatever I try, including with testgreg_wstream.cpp. The only way I've been able to get my code working is to define BOOST_DATE_TIME_NO_WSTRING_CONVERSIONS, and then convert to wchar_t myself.
I'll check the CVS dates in a bit, but this leads me to believe you aren't actually using VC7.1? Is that somehow possible? The only other conclusion would be that the regression tests are somehow getting NO_WSTRING conversions set when they are run...
Jeff
I've definitely only got VC7.1 on my PC, so that's not the issue. As to
OK, I've found the missing compiler option: /Zc:wchar_t (treat wchar_t as a
built-in type), in vc7.1-tools.jam in tools\build\v1. However, as that
option breaks the wxWidgets library, I cannot use it. Can the date_time
library be made to also work when wchar_t is a typedef to unsigned short?
Thanks,
Keith MacDonald
"Keith MacDonald"
regression tests, I was not familiar with how to build and run them, so I simply tried to compile testgreg_wstream.cpp on its own, using "cl /EHsc /I \CVS\boost". As it failed to compile, there was no question of getting NO_WSTRING conversions.
Having just read up on how to run the regression tests, I've successfully built and run those for date_time, so there must be something simple wrong with my compiler options. What else do I need, apart from "cl /EHsc /I \CVS\boost" -which is sufficient for the regex library?
Thanks, Keith MacDonald
"Jeff Garland"
wrote in message news:20040314162844.M66082@crystalclearsoftware.com... On Sun, 14 Mar 2004 16:07:41 -0000, Keith MacDonald wrote
Thanks for your response.
I get the same results whatever I try, including with testgreg_wstream.cpp. The only way I've been able to get my code working is to define BOOST_DATE_TIME_NO_WSTRING_CONVERSIONS, and then convert to wchar_t myself.
I'll check the CVS dates in a bit, but this leads me to believe you aren't actually using VC7.1? Is that somehow possible? The only other conclusion would be that the regression tests are somehow getting NO_WSTRING conversions set when they are run...
Jeff
Just include
OK, I've found the missing compiler option: /Zc:wchar_t (treat wchar_t as a built-in type), in vc7.1-tools.jam in tools\build\v1. However, as that option breaks the wxWidgets library, I cannot use it. Can the date_time library be made to also work when wchar_t is a typedef to unsigned short?
Thanks, Keith MacDonald
Thanks for the suggestion. The problem is that I'm statically linking to a
Unicode build of wxWidets, so I get unresolved external symbols such as:
"wchar_t const * const wxDialogNameStr"
"wchar_t const * const wxButtonNameStr"
"public: static void __cdecl wxObject::operator delete(void *,wchar_t const
*,int)"
"public: wchar_t const * __thiscall wxLocale::GetString(wchar_t const
*,wchar_t const *)const"
I'll have to figure out how to build wxWidgets with /Zc:wchar_t
- Keith MacDonald
"George Diamantopoulos"
Just include
after your wxwidgets include and before the boost::date one. Let me know if it works :)
George Diamantopoulos
Keith MacDonald wrote:
OK, I've found the missing compiler option: /Zc:wchar_t (treat wchar_t as a built-in type), in vc7.1-tools.jam in tools\build\v1. However, as that option breaks the wxWidgets library, I cannot use it. Can the date_time library be made to also work when wchar_t is a typedef to unsigned short?
Thanks, Keith MacDonald
wchar_t is defined in that file as typedef unsigned short wchar_t; Did you compile your wxwidgets using /Zc:wchar_t? If so, try disabling that and including wctype.h instead. George Diamantopoulos Keith MacDonald wrote:
Thanks for the suggestion. The problem is that I'm statically linking to a Unicode build of wxWidets, so I get unresolved external symbols such as:
"wchar_t const * const wxDialogNameStr" "wchar_t const * const wxButtonNameStr" "public: static void __cdecl wxObject::operator delete(void *,wchar_t const *,int)" "public: wchar_t const * __thiscall wxLocale::GetString(wchar_t const *,wchar_t const *)const"
I'll have to figure out how to build wxWidgets with /Zc:wchar_t
- Keith MacDonald
On Sun, 14 Mar 2004 18:05:13 -0000, Keith MacDonald wrote
OK, I've found the missing compiler option: /Zc:wchar_t (treat wchar_t as a built-in type), in vc7.1-tools.jam in tools\build\v1. However, as that option breaks the wxWidgets library, I cannot use it. Can the date_time library be made to also work when wchar_t is a typedef to unsigned short?
Good work tracking that down. It looks like maybe there is already a boost config for this. That is BOOST_NO_INTRINSIC_WCHAR_T Could you see if this is defined when you you compile without the /Zc:wchar_t option on VC7.1? If this is defined I can just use it to define BOOST_DATE_TIME_NO_WSTRING_CONVERSIONS which would take care of the problem. Jeff
participants (5)
-
Adel Essafi
-
George Diamantopoulos
-
Jeff Garland
-
Keith MacDonald
-
Paul Grenyer