|
[c++] "warning: statement has no effect" |
Mark Oates
Member #1,146
March 2001
|
I'm getting this message using a for loop that actually does have an affect. How can I turn off this warning? Oh, and while I'm at it how do I turn off "multiple definition" errors? -- |
Matthew Leverton
Supreme Loser
January 1999
|
Write for (a;b;c); as for (a;b;c) {}. |
Mark Oates
Member #1,146
March 2001
|
It already is. The for loop is from tinyXML's recommended method for reading from the document: TiXmlElement* gimp_element; for(gimp_element; gimp_element; gimp_element=gimp_element->NextSiblingElement()) { ... }
-- |
ReyBrujo
Moderator
January 2001
|
Quote: Oh, and while I'm at it how do I turn off "multiple definition" errors? Correcting the code. That usually means you have defined a variable in a header that is being included in several. Declare the variable as extern in the header, and define it once in a source file without the modifier. And try initializing the iterator variable. -- |
Matthew Leverton
Supreme Loser
January 1999
|
Change it to: for(gimp_element; gimp_element; (gimp_element=gimp_element->NextSiblingElement())) { }
|
Mark Oates
Member #1,146
March 2001
|
ah-hah! -- |
Matthew Leverton
Supreme Loser
January 1999
|
And by the way, if your for loop has no affect, it might suffer from schizophrenia. |
ReyBrujo
Moderator
January 2001
|
{"name":"effect_an_effect.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/c\/cc83c72c4c0078e428278e3a82ebf2c4.png","w":340,"h":423,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/c\/cc83c72c4c0078e428278e3a82ebf2c4"} -- |
Mark Oates
Member #1,146
March 2001
|
Quote: it might suffer from schizophrenia. it does. -- |
Kitty Cat
Member #2,815
October 2002
|
Quote: for(gimp_element; gimp_element; gimp_element=gimp_element->NextSiblingElement()) The first part of the for statement (where it sets the initial pre-loop setting) has no effect. That for loop would be rewritten as: TiXmlElement* gimp_element; gimp_element; while(gimp_element) { ... gimp_element=gimp_element->NextSiblingElement(); }
-- |
Johan Halmén
Member #1,550
September 2001
|
http://www.allegro.cc/files/attachment/593802 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
Matthew Leverton
Supreme Loser
January 1999
|
Quote: The first part of the for statement Unless there's a clever macro going on; after all, this is C++. |
Tobias Dammers
Member #2,604
August 2002
|
I don't think you even need a macro to really fsck things up badly.
Untested though. --- |
CGamesPlay
Member #2,559
July 2002
|
Looks like you increment twice -- Ryan Patterson - <http://cgamesplay.com/> |
|