Program does not run outside of the IDE

This is a discussion on Program does not run outside of the IDE within the C++ Programming forums, part of the General Programming Boards category; I'm lost here - without the slightest idea what could be wrong. The code runs (compiles and executes) fine in ...

  1. #1
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314

    Program does not run outside of the IDE

    I'm lost here - without the slightest idea what could be wrong. The code runs (compiles and executes) fine in the Dev C++ IDE but as soon as I try to execute the linked file from the windows explorer, nothing happens. No error message, nothing.

    I have tracked it down to the first line in my WinMain function that says:

    CGLRenderer renderer;

    CGLRenderer is a very simple OpenGL wrapper I coded for a small testproject. Everything in the CGLRenderer constructor is executed properly but then instead of executing the rest of my code, the program exits to windows.
    The constructor looks like this: (Notice the 3 filestream lines that are commented out.)

    Code:
    CGLRenderer::CGLRenderer() {
    	p= new TGLRendererPriv;
    
    	// ofstream a_file("bm.log", ios::app);
    	// a_file << "lifesign" << endl;
    	// a_file.close();
    
    	p->hHostWnd=			NULL;
    	p->hDC=				NULL;
    	p->hRC=				NULL;
    	p->iHostWidth=			0;
    	p->iHostHeight=			0;
    
    	p->iVertexArrayStride=		0;
    	p->pVertexArray= 		NULL;
    	
     	for (int i; i <= MAX_TEXLAYERS; i++) {
    	  p->aiTexCoordArrayStride[i]=	0;
    	  p->apTexCoordArray[i]= 	NULL;
     	}
     	
     	p->glActiveTextureARB=		NULL;
    	p->glClientActiveTextureARB=	NULL;
    }
    p-> is the pointer to the private implementation struct (greetings, Cat ) which looks like this:

    Code:
    struct CGLRenderer::TGLRendererPriv {
    	HWND	hHostWnd; 
    	HDC	hDC;
    	HGLRC	hRC;
    	int	iHostWidth, iHostHeight;
    	void	*pVertexArray;
    	int	iVertexArrayStride;
     	void	*apTexCoordArray[MAX_TEXLAYERS];
     	int	aiTexCoordArrayStride[MAX_TEXLAYERS];
    	PFNGLACTIVETEXTUREARBPROC
    		glActiveTextureARB;
    	PFNGLCLIENTACTIVETEXTUREARBPROC
    		glClientActiveTextureARB;
    };
    When I launch the programm with the Windows Explorer, the code in the constructor is executed and then the program exits. Since I couldn't use the debugger (it works fine there) I added those 3 lines of code that simply create a file as soon as they are processed to allow me to track down where the problem is.

    Now the stange thing: The program runs as soon as I uncomment the filestream lines. All of it, not just the constructor.

    I know, I could leave the filestream stuff in the constructor and let if be, but there must be a reason why it doesn't work without it. I assume it's something so simple that I just can't see it.

    Any help would be appreciated
    - a lost C++ newbie...

    ps: I'm using winxp, latest dev c++. The class CGLRenderer is derived from an abstract baseclass, but this can't be the reason because the problem occured even after I eliminated the baseclass.

  2. #2
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by Salem
    > for (int i; i <= MAX_TEXLAYERS; i++)
    Well if nothing else, I would initialise i to 0, and make sure it kept in bounds of the arrays it is indexing

    for (int i = 0; i < MAX_TEXLAYERS; i++)

    Thank you very much, Salem!

    That really was it, the reason of all the trouble. I think I would have never found this...

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    yeah, I don't know how DevC++ does things but in Visual studios, you can have different results from debug to release mode builds. One example is a mismatched calling convention. If you don't get that right in release mode it can cause a crash that Debug mode didn't cause.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #4
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by FillYourBrain
    yeah, I don't know how DevC++ does things but in Visual studios, you can have different results from debug to release mode builds. One example is a mismatched calling convention. If you don't get that right in release mode it can cause a crash that Debug mode didn't cause.
    The delphi compiler used to have a switch to build the file with type and overflow checks so you get an exception if something goes wrong. Of course thats extremely slow and you wouldn't release such a file, but it was nice to see where the problem is.

    I guess I should check the MinGW manpages if there's a switch to turn that on. Does anyone know if overflow checked build are possible with the MSVC++ compiler?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 02:30 PM
  3. Re-doing a C program to run in Win2000 or XP
    By fifi in forum C Programming
    Replies: 5
    Last Post: 08-17-2007, 05:32 PM
  4. Replies: 3
    Last Post: 07-11-2005, 03:07 AM
  5. plz help me run this program!!!
    By galmca in forum C Programming
    Replies: 8
    Last Post: 02-01-2005, 12:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21