g++4.5.2 cann't compile (Formatting a Date/Time as a String)
eric
fsshl at att.net
Mon Jul 11 04:52:51 UTC 2011
Dear Ubuntu programers by g++:
I copied a piece simple (Formatting a Date/Time as a String) program
from book(c++ cookbook), chapter5 Section2, Example5-4, on page 201.
on my g++4.5.2(ubuntu10.04, with kernel 2.6.35-25)
you can get that example code from
http://examples.oreilly.com/9780596007614/
to test by yourself
I got compile errors
------------------------
eric at eric-laptop:~/cppcookbook/ch5$ g++ Example5-4.cpp
Example5-4.cpp: In function ‘std::ostream& formatDatetime(std::ostream&,
const tm&, const char*)’:
Example5-4.cpp:16:17: error: invalid use of incomplete type ‘const
struct std::time_put<char>’
/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c
++/4.5.2/bits/localefwd.h:163:11: error: declaration of ‘const struct
std::time_put<char>’
Example5-4.cpp: In function ‘std::string dateTimeToString(const tm&,
const char*)’:
Example5-4.cpp:24:31: error: ‘formatDateTime’ was not declared in this
scope
In file included
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c
++/4.5.2/bits/locale_classes.h:815:0,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c
++/4.5.2/bits/ios_base.h:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c
++/4.5.2/ios:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c
++/4.5.2/ostream:40,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c
++/4.5.2/iostream:40,
from Example5-4.cpp:2:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c
++/4.5.2/bits/locale_classes.tcc: In function ‘const _Facet&
std::use_facet(const std::locale&) [with _Facet = std::time_put<char>]’:
Example5-4.cpp:14:77: instantiated from here
/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c
++/4.5.2/bits/locale_classes.tcc:107:43: error: incomplete type
‘std::time_put<char>’ used in nested name specifier
/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c
++/4.5.2/bits/locale_classes.tcc:112:56: error: cannot dynamic_cast ‘*
*(__facets + ((unsigned int)(((unsigned int)__i) * 4u)))’ (of type
‘const class std::locale::facet’) to type ‘const struct
std::time_put<char>&’ (target is not pointer or reference to complete
type)
eric at eric-laptop:~/cppcookbook/ch5$
----------------------------------------------------------------
need your help to fix it
and thanks a lot in advance
Eric
More information about the Ubuntu-devel-discuss
mailing list