http://examples.oreilly.com/9780596007614/ both book and last time I copied, that example code did not have #include <locale> Thanks your help On Mon, Jul 11, 2011 at 1:08 AM, Axel Freyn <axel-freyn@xxxxxx> wrote: > Hi eric, > On Sun, Jul 10, 2011 at 11:32:56PM -0700, eric wrote: >> 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::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>’ > > I assume it's the same problem as with most of your examples: this > is probably no valid C++ code. You use the class std::time_put in file > Example5-4.cpp, line 16. But in the headers you include, this class is > only forward declared, but not defined ==> the compiler can't continue. > Did you really include <locale> ? > > Axel > >