Jump to content
  • Advertisement
Sign in to follow this  
MPG

Is Visual C++ having a hard time reading my code?

This topic is 5147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

It keeps on saying c:\Documents and Settings\Randle\Desktop\randyx's stuff\PROJECTS\move image\mo.cpp(80): error C2065: 'screen' : undeclared identifier This is starting to bug me. The Eerror is on the line SDL_Flip (Screen);.Heres my code{I erased semicolons):
#ifdef WIN32
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#endif
#include "SDL.h"

void run()
 {
	 Uint32 dt;
	 Uint32 move;
	 move = SDL_GetTicks();
	 SDL_Rect dest;
      Uint32 lastframe;
	 move =  SDL_GetTicks() - move
        
		dest.x += 2 * lastframe;
	      dest.y += 2 * lastframe;
 }

int main( int argc, char* argv[] )
{
Uint32 lastframe=SDL_GetTicks();
while(true) {
  Uint32 dt=SDL_GetTicks()-lastframe;
  lastframe=SDL_GetTicks();
	Uint32 move;
  SDL_Init( SDL_INIT_VIDEO );  
 move = SDL_GetTicks()

  SDL_Surface * screen = SDL_SetVideoMode( 800,600, 24, SDL_ANYFORMAT|SDL_DOUBLEBUF );  
  SDL_Surface * img = SDL_LoadBMP( "filename.bmp" );   
  SDL_Rect dest;  
  dest.x = 2;  
  dest.y = 2;  
  SDL_Event event;
  SDL_Event a;//saving for later use//
  SDL_Event b;//saving for later use//
  SDL_Event Event  //saving for later use//            
	 SDL_Rect coord
			 coord.x = 200;
			 coord.y = 500;
			 SDL_Surface * tdisplay = SDL_SetVideoMode( 800,600,24,SDL_ANYFORMAT|SDL_DOUBLEBUF );
			 SDL_Surface * imi = SDL_LoadBMP( "ad.bmp" );
             SDL_Surface * bckg = SDL_LoadBMP ( "bg.bmp" );
               
				SDL_Flip( screen );
                  Uint32 now;

   
 while(true) {		
	  SDL_BlitSurface(img,NULL,screen, &dest);		
	  SDL_PollEvent(&event);		
	  if(event.type == SDL_MOUSEBUTTONDOWN) 
	  {			
		  if(event.button.button == SDL_BUTTON_LEFT) 
		  {				
		    
			  SDL_BlitSurface(imi,NULL,tdisplay,&coord);				
		      SDL_Flip(tdisplay);
			  	   
		  }
	  }	
 }
if(event.type == SDL_QUIT) 
{ 
	return 0; 
}
  
	  SDL_Event up;
	  while(true){
	if(up.type == SDL_KEYDOWN)
	{
		if(up.key.keysym.sym == SDLK_SPACE)
		{
          run()
		}
	}
	  }
} 
		SDL_Flip( screen );
     atexit(SDL_Quit);
  return 0;
		}
  


I reinstaled it,but it did'nt help

Share this post


Link to post
Share on other sites
Advertisement
Declare the screen pointer outside of the while loop. It looses it's scope.

Lizard

EDIT: And don't take away semicolons from you posted code in the future =)

Share this post


Link to post
Share on other sites
You mustn't call SDL_Init(SDL_INIT_VIDEO) multiple times like that. Generally once per program is enough. The same goes for SDL_SetVideoMode. You will need to really think about your code because I don't think that will do anything like what you want it to.

Share this post


Link to post
Share on other sites
error C2501: 'atexit' : missing storage-class or type specifiers
error C2440: 'initializing' : cannot convert from 'void (__cdecl *)(void)' to 'int'
: error C2365: 'atexit' : redefinition; previous definition was a 'function'
error C2143: syntax error : missing ';' before '}'
error C2059: syntax error : '}'
missing ';' before '}'
error C2059: syntax error : '}'
grrrrrrr!!!!!!What going on?

Share this post


Link to post
Share on other sites
You need to include a header file for atexit. The rest is probably down to your missing semi-colons and so on. Remember, terminate every statement with a semi-colon.

Share this post


Link to post
Share on other sites
It givesme linking error that I can't read.
msvcrt.lib(MSVCR71.dll) : error LNK2005: _exit already defined in LIBCD.lib(crt0dat.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: _strncpy already defined in LIBCD.lib(strncpy.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: _fclose already defined in LIBCD.lib(fclose.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: __isctype already defined in LIBCD.lib(isctype.obj)
LIBCD.lib(crt0init.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/move image.exe : fatal error LNK1169: one or more multiply defined symbolS
Anyone know of a tutorial on reading errors?

Share this post


Link to post
Share on other sites
thanks a linking error. im assuming your using VS.net by the looks of how you included your libraries. try switching the "code generation" in to "Multi-threaded DLL".

click view, then solution explorer

right click the project name, go to properties

click the C++ folder

click Code Generation

in the Runtime Library field, set it to Multi-Threaded DLL (/MD). it might also work using Multi threaded debug DLL.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!