why why why open in debugger!!!!???

God damn this is irritating me.

All the code is fine.

… But note the int marioBase = 0; in setup and skip ahead

  
#include "testApp.h"  
  
  
//--------------------------------------------------------------  
void testApp::setup(){	   
  
width = ofGetWidth() - 2;  
height = ofGetHeight() - 2;  
  
int marioBase = 0;  
  
  
stringstream nameBuilder;  
for (int i = 0; i < 3; i++){  
     nameBuilder << "MarioMedium" << i << ".jpg";  
     Mario_run[i].loadImage(nameBuilder.str());  
	 Mario_run[i].resize(Mario_run[i].width*4,Mario_run[i].height*4);  
	 Mario_run[i].setImageType(OF_IMAGE_COLOR_ALPHA);  
	   
	 string test = nameBuilder.str();  
	 printf("loading: %s\n", test.c_str());  
	   
     nameBuilder.str("");  
}  
  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
  
  
// marioHeight = marioBase; // variable that varies!  
  
clock = (ofGetElapsedTimeMillis() / 85);  
loop = clock % 3;  
  
// whether to loop or not  
if (play) { animate = loop; }   
else { for (animate = loop; loop !=0; loop = animate) { animate = 0; } } // loop through until reach frame 0 then stop  
  
// whether to jump mario  
// if (jump) { /* jump up */ for (int i = 0; i < 50; i++){ marioHeight--; } /* fall down */ for (int i = 0; i < 50; i++){ marioHeight++; } jump = false; }  
//	else { marioHeight = marioBase; }  
	  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
  
  
  
// the magic one line of code:  
Mario_run[animate].draw(2, (height - Mario_run[animate].height)); // loop = animate through the series of images  
  
	  
	  
	  
	char tempStr[255];  
	  
	// ofSetColor(0x000000);  
	sprintf(tempStr, "Elapsed Time Function: %i", loop);  
	ofDrawBitmapString(tempStr, 400,height);  
  
}  
  
//--------------------------------------------------------------  
void testApp::keyPressed  (int key){   
	  
}  
  
//--------------------------------------------------------------  
void testApp::keyReleased  (int key){   
	  
}  
  
//--------------------------------------------------------------  
void testApp::mouseMoved(int x, int y ){  
}  
  
//--------------------------------------------------------------  
void testApp::mouseDragged(int x, int y, int button){  
}  
  
//--------------------------------------------------------------  
void testApp::mousePressed(int x, int y, int button){  
  
// temporary start stop button (until play button is created)  
if (play){  
play = false;  
} else {  
play = true;  
}  
  
}  
  
//--------------------------------------------------------------  
void testApp::mouseReleased(){  
  
  
}  
  

it works fine and lovely. BUT when I declare marioBase in my testApp.h and remove the ‘int’ declaration from setup, to treat marioBase like any normal variable. the program no longer compiles and runs in debugger mode. despite not telling it to do so. I get no errors and the compiler tells me ‘successful’

This is in xCode 2.5

WTF!?!?

here’s the friggin header file:

  
#ifndef _TEST_APP  
#define _TEST_APP  
  
  
#include "ofMain.h"  
#include "ofAddons.h"  
  
class testApp : public ofSimpleApp{  
	  
	public:  
		  
		void setup();  
		void update();  
		void draw();  
		  
		void keyPressed(int key);  
		void keyReleased(int key);  
		void mouseMoved(int x, int y );  
		void mouseDragged(int x, int y, int button);  
		void mousePressed(int x, int y, int button);  
		void mouseReleased();  
		  
		ofImage Mario_run[3];  
		int clock, loop, animate;  
		bool play;  
		  
		int width, height;  
		  
		int marioBase;  
};  
  
#endif  
	  
  

Thanks again, really appreciate it.

What the!?

moving int marioBase; up a few lines to before ofImage Mario_run[3]; fixes this!?

Does this sound like a bug or programming ignorance?

and now I’m struggling to introduce another variable :cry:

so I’m now putting new declarations of variables at the top of the .cpp file.

Sorry for the machine gun posting but I thought these updates are relevant.

What happens if you “clean” the project, shut down XCode, reboot and try again? Does it still occur?

XCode 2.5 is a fairly old version by now, but I suppose it should still be fine. Otherwise try updating to something more recent.

[quote author=“arif”]What the!?

moving int marioBase; up a few lines to before ofImage Mario_run[3]; fixes this!?

Does this sound like a bug or programming ignorance?[/quote]

There’s a reason why the debugger steps in. Most of the time this happens, when you write into memory, which is not part of the particular object, or outside of the scope of an array. These are hard to debug, I’d switch to std::vectors and create my ofImages on the heap.

cheers,
Stephan