C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sstream kennt ostringstream nicht

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Beate Mielke
Guest





PostPosted: Sun Nov 16, 2003 10:17 am    Post subject: sstream kennt ostringstream nicht Reply with quote



Hallo,

ich habe beim Ausführen eines Makefiles die Meldung bekommen. "Kann Datei
strstream.h nicht finden".
Ich benutze Suse 8.2.
Die Datei ist "deprecated" und deshalb habe ich anstattdessen "sstream"
benutzt, wie es überall beschrieben steht. Außerdem soll man "ostrstream" im
c++-Programm durch "ostringstream" ersetzen. Auch das habe ich gemacht.
Jetzt bekomme ich aber regelmäßig die Meldung: "'ostringstream' undeclared
(first use of this function)".
Und das, obwohl die Datei "sstream" gefunden wird.

Hat jemand eine Idee?

Viele Grüße

Beate

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Markus Breuer
Guest





PostPosted: Sun Nov 16, 2003 10:42 am    Post subject: Re: sstream kennt ostringstream nicht Reply with quote



Beate Mielke schrieb:
Quote:
Hallo,

ich habe beim Ausführen eines Makefiles die Meldung bekommen. "Kann Datei
strstream.h nicht finden".
Ich benutze Suse 8.2.
Die Datei ist "deprecated" und deshalb habe ich anstattdessen "sstream"
benutzt, wie es überall beschrieben steht. Außerdem soll man "ostrstream" im
c++-Programm durch "ostringstream" ersetzen. Auch das habe ich gemacht.
Jetzt bekomme ich aber regelmäßig die Meldung: "'ostringstream' undeclared
(first use of this function)".
Und das, obwohl die Datei "sstream" gefunden wird.

Hat jemand eine Idee?

Vermutlich hast du einfach den namepace vergessen. Genaugenommen heissen
ostringstream und ostream nämlich std::ostringstream und std::ostream.

Gruß Markus

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Beate Mielke
Guest





PostPosted: Sun Nov 16, 2003 1:51 pm    Post subject: Re: sstream kennt ostringstream nicht Reply with quote



Hallo Markus,

Quote:
Vermutlich hast du einfach den namepace vergessen. Genaugenommen heissen
ostringstream und ostream nämlich std::ostringstream und std::ostream.

danke, das war's tatsächlich, aber das scheint erst die "richtigen" Fehler
ausgelöst zu haben. Vieleicht hast Du Lust, mal draufzusehen:

aufrufendes Programm:
---snip
....
char*
Timer::print()
{
static char s[20];
std::ostringstream str(s, sizeof(s));
...
return str.str();
}
....
---snap

Neue Fehlermeldung bei der Ausführung des Makefiles:

---snip
....
aufruf.cc: In member function 'char* Timer::print()'
error: invalid conversion from 'unsigned int' to
'std::_Ios_Openmode'
error: initializing argument 2 of
'std::basic_ostringstream<_charT, _Traits,
_Alloc>::basic_ostringstream(const
std::basic_string<_charT, _Traits,
_Alloc>&, std::_Ios_Openmode)
[with _CharT= char, _Traits=std::char_traits<char>,
_Alloc=std::allocator<char>]'
error: cannot convert 'std::basic_string<char,
std::traits'
to 'char*' in return
....
---snap

Ich kriege langsam wirklich die Krise, weil ich seit Tagen versuche dieses
Programm zu installieren.
Danke im Voraus.

Beate

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Thomas Maeder
Guest





PostPosted: Sun Nov 16, 2003 8:26 pm    Post subject: Re: sstream kennt ostringstream nicht Reply with quote

"Beate Mielke" <bmx.net (AT) gmx (DOT) net> writes:

Quote:
danke, das war's tatsächlich, aber das scheint erst die "richtigen" Fehler
ausgelöst zu haben. Vieleicht hast Du Lust, mal draufzusehen:

aufrufendes Programm:
---snip
...
char*
Timer::print()
{
static char s[20];
std::ostringstream str(s, sizeof(s));

std::ostringstream hat keinen Konstruktor, der auf diese Definition passt.

Wenn Du aber die beiden Zeilen durch

std::ostringstream str;

ersetzt und in den folgenden ...

Quote:
...

<< ends

entfernst, kriegst Du ungefähr das gleiche Verhalten hin wie früher mit
std::ostrstream. Der Unterschied besteht darin, dass die neue Variante intern
dynamisch Speicher alloziert.


Quote:
Ich kriege langsam wirklich die Krise, weil ich seit Tagen versuche dieses
Programm zu installieren.

Für dieses Problem gibt's andere Newsgroups :-)

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Markus Breuer
Guest





PostPosted: Sun Nov 16, 2003 8:30 pm    Post subject: Re: sstream kennt ostringstream nicht Reply with quote

Quote:
danke, das war's tatsächlich, aber das scheint erst die "richtigen" Fehler
ausgelöst zu haben. Vieleicht hast Du Lust, mal draufzusehen:

aufrufendes Programm:
---snip
....
char*
Timer::print()
{
static char s[20];
std::ostringstream str(s, sizeof(s));
...
return str.str();
}
....
---snap

Vermutlich hat der strstream vormals 's' gefüllt. ostringstream verhält
sich da ein wenig anders, vor allem in der Konstruktion. Versuche mal
folgendes:

char*
Timer::print()
{
static char s[20];
std::ostringstream str;
...
std::string data( str.str() );
strncpy( s, data.data(), sizeof(s)-1);
s[ sizeof(s)-1 ] = 0;
return s;
}

Gruß Markus

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Beate Mielke
Guest





PostPosted: Mon Nov 17, 2003 8:50 pm    Post subject: Re: sstream kennt ostringstream nicht Reply with quote

Hallo Markus,

Quote:
... Versuche mal folgendes:

char*
Timer::print()
{
static char s[20];
std::ostringstream str;
...
std::string data( str.str() );
strncpy( s, data.data(), sizeof(s)-1);
s[ sizeof(s)-1 ] = 0;
return s;
}

Hat auf Anhieb ohne Fehler geklappt.
Vielen Dank für Deine Hilfe!!!

Gruß Beate

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Beate Mielke
Guest





PostPosted: Mon Nov 17, 2003 8:52 pm    Post subject: Re: sstream kennt ostringstream nicht Reply with quote

Hallo Thomas,

Quote:
Wenn Du aber die beiden Zeilen durch

std::ostringstream str;

ersetzt und in den folgenden ...

...

ends

entfernst, kriegst Du ungefähr das gleiche Verhalten hin wie früher mit
std::ostrstream. Der Unterschied besteht darin, dass die neue Variante
intern
dynamisch Speicher alloziert.

Das hat leider nicht funktioniert, aber Markus hat eine funktioniernde
Lösung aufgeschrieben, jetzt bin ich wenigstens gerettet.

Quote:
Für dieses Problem gibt's andere Newsgroups Smile


lol ...

Gruß Beate

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.