E
eric
Dear c++ programers:
If you are also an g++ programers, especially ever create/modify its
source code, I need your help
I have a piece simple code about formatting a date/time as a string
from a book. its authors claim it work in vc++7.1 on xp.
but my g++4.5.2 didn't pass it on compile stage
-------------------------------------------------------------------------------------------
eric@eric-laptop:~/cppcookbook/ch5$ g++ Example5-4.cpp
Example5-4.cpp: In function ‘std:stream&
formatDatetime(std:stream&, 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@eric-laptop:~/cppcookbook/ch5$
If you are also an g++ programers, especially ever create/modify its
source code, I need your help
I have a piece simple code about formatting a date/time as a string
from a book. its authors claim it work in vc++7.1 on xp.
but my g++4.5.2 didn't pass it on compile stage
-------------------------------------------------------------------------------------------
eric@eric-laptop:~/cppcookbook/ch5$ g++ Example5-4.cpp
Example5-4.cpp: In function ‘std:stream&
formatDatetime(std:stream&, 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@eric-laptop:~/cppcookbook/ch5$