Sign in to follow this  

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

This topic is 4838 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
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
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
There are many threads, articles, tutorials etc. on this subject, so you should check them out, before asking here. For example, you may visit my thread named "Yet another framerate independent movement in SDL", it's in this forum. There you'll find one good, working code example of independent frame movement.

Additionaly, you may check this out: http://2dnow.zenzer.net/viewarticle.php?a=5. There's also one article here on GameDev.
And remember: google is your friend :-]

Share this post


Link to post
Share on other sites

This topic is 4838 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this