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 

warning: value computed is not used

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





PostPosted: Mon Mar 07, 2005 8:01 am    Post subject: warning: value computed is not used Reply with quote



hallo
benutze die PRC-Tools (g++) für PalmOS

m_value ist ein 4 Byte großes char-Array um die 4 Bytes einer long Variablen
aufzunehmen.
um später diesen long Wert auch an einer NICHT 2 oder 4 Byte Grenze im
Datensatz ausrichten zu können.

void CTLong::operator = (long l)
{
swap32((unsigned long)l); // l ist swap32 erwartet eine Referenz auf
long
memcpy(m_value, &l, 4); // hier tritt die Warung auf
}

Ich hatte eine früher mal die gleiche Warnung auch bei memcpy, hatte Sie
aber bisher ignoriert weil es halt funktionierte, möchte nun aber
doch mal fragen, was hier denn nun berechnet aber nicht verwendet wird ?

Vielen Dank im Voraus.
mfg
Martin Bauer

--
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
Stefan Reuther
Guest





PostPosted: Mon Mar 07, 2005 10:18 am    Post subject: Re: warning: value computed is not used Reply with quote



Martin Bauer wrote:
Quote:
void CTLong::operator = (long l)
{
swap32((unsigned long)l); // l ist swap32 erwartet eine Referenz auf long

Hat zwar vermutlich nichts mit dem Problem zu tun, aber wenn du meinst,
dass swap32 eine Referenz auf *unsigned long* haben willst, solltest du
ihm auch eine geben: 'swap32((unsigned long&) l)'. So dürfte das nicht
compilieren.

Quote:
memcpy(m_value, &l, 4); // hier tritt die Warung auf

Die Warnung besagt vermutlich, dass 'memcpy' einen von void
verschiedenen Wert zurückliefert. Tut es ja auch; memcpy liefert sein
erstes Argument zurück. Übervorsichtige Programmierer casten in so einem
Fall nach void: '(void) memcpy(m_value, &l, 4)'. Da halte ich aber nicht
allzuviel davon, ich hielte es für zielführender, dem Compiler diese
spezielle Warnung abzugewöhnen, falls das möglich ist (für eine Zeile
wie 'somefunc;' statt 'somefunc()' will man natürlich weiterhin eine
Warnung haben). Aber eigentlich alle memXXX- und strXXX-Funktionen
liefern einen Wert, den man in 99% aller Fälle ignoriert.


Stefan

--
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.