Hi,
Ok. I'm not a C++ programmer, and would appreciate an explanation. The
standalone code is:
#include <iostream>
#include <sstream>
#include <time.h>
using namespace std;
class DateTime {
public:
DateTime();
virtual ~DateTime() {}
operator tm() const;
protected:
long i;
};
class EpsBufr {
public:
EpsBufr();
virtual ~EpsBufr() {};
void doit();
protected:
DateTime base_;
};
DateTime::operator tm() const
{
struct tm tm_date = tm();
return tm_date;
}
void EpsBufr::doit() {
ostringstream out;
tm convert = base_;
locale loc("");
const std::time_put<char>& tfac =
use_facet<time_put<char> >(loc);
string format = "Forecast VT %A %e %B %Y %H UTC";
tfac.put(out, out, ' ', &convert, format.c_str(),
format.c_str()+format.length());
}
This compiles and works with g++ 4.1, and intel CC 11. With g++-4.3
(Debian 4.3.3-7) 4.3.3 I get the error:
test.cc: In member function ‘void EpsBufr::doit()’:
test.cc:38: error: invalid use of incomplete type ‘const struct
std::time_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> > >’
/usr/include/c++/4.3/bits/localefwd.h:162: error: declaration of
‘const struct std::time_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> > >’
/usr/include/c++/4.3/bits/locale_classes.tcc: In function ‘const
_Facet& std::use_facet(const std::locale&) [with _Facet =
std::time_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> > >]’:
test.cc:36: instantiated from here
/usr/include/c++/4.3/bits/locale_classes.tcc:112: error: incomplete
type ‘std::time_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> > >’ used in nested name specifier
/usr/include/c++/4.3/bits/locale_classes.tcc:117: 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, std::ostreambuf_iterator<char,
std::char_traits<char> > >&’ (target is not pointer or reference to
complete type)
I don't really understand the first line (Not really a C++ programmer)
but why is it giving error messages about the standard includes?
An explanation would help: if g++ 4.3 is correct then good, and I'll
file a report with Intel for compiling it!
Thanks
Alastair
On 14 Apr 2009, at 17:24, Bastian Blank wrote:
tags 524064 moreinfo
thanks
On Tue, Apr 14, 2009 at 05:17:59PM +0100, Alastair McKinstry wrote:
Relevant code:
196 ostringstream out;
197 tm convert = base_;
198 locale loc("");
199 out.imbue(loc);
200 const std::time_put<char>& tfac =
use_facet<time_put<char> >(loc);
201 string format = "Forecast VT %A %e %B %Y %H UTC";
202 tfac.put(out, out, ' ', &convert, format.c_str(),
format.c_str()+format.length());
Please provide a _working_ (or failing) snippet which shows the
behaviour. This one will be rejected by the compiler always, because
of
missing includes and function body. Also please show why you think
this
code is correct.
This code compiles fine with g++-4.1.
gcc 4.3 got more strict for missing includes, so you need to show that
it is not such a problem.
Bastian
--
The more complex the mind, the greater the need for the simplicity
of play.
-- Kirk, "Shore Leave", stardate 3025.8
Regards,
Alastair
--
Alastair McKinstry , <alast...@sceal.ie> http://blog.sceal.ie
Anyone who believes exponential growth can go on forever in a finite
world
is either a madman or an economist - Kenneth Boulter, Economist.
--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org