# What do these errors mean

## Recommended Posts

(10) : error C2440: '=' : cannot convert from 'Uint32 (__cdecl *)(void)' to 'Uint32' This conversion requires a reinterpret_cast, a C-style cast or function-style cast(15) : error C2296: '-' : illegal, left operand has type 'Uint32 (__cdecl *)(void)' edit: added proper code tags
#ifdef WIN32
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#endif
#include "SDL.h"

;void run()
{
Uint32 move;
move = SDL_GetTicks;
SDL_Rect dest;

move =  SDL_GetTicks - move

;dest.x += 100 * move;
dest.y += 100 * move
;}

int main( int argc, char* argv[] )
{
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 = 100;
dest.y = 100;
SDL_Event event;
SDL_Event a;
SDL_Event b;
SDL_Event Event
;SDL_Rect coord
;coord.x = 200;
coord.y = 500;
SDL_Surface * tdisplay = SDL_SetVideoMode( 800,600,24,SDL_ANYFORMAT|SDL_DOUBLEBUF );
SDL_Surface * bckg = SDL_LoadBMP ( "bg.bmp" );

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;

if(up.type == SDL_KEYDOWN)
{
if(up.key.keysym.sym == SDLK_UP)
{
run()
;}
}
SDL_Flip( screen );

return 0;

}

[Edited by - hplus0603 on September 5, 2004 12:12:14 PM]

##### Share on other sites
move = SDL_GetTicks;SDL_Rect dest;move = SDL_GetTicks - move

SDL_GetTicks is a function, so it should be SDL_GetTicks()

[smile]

(The error says that it can't convert from a function pointer to an integer..)

##### Share on other sites
bah,I always make mistacks like that,but it still wont move.
Do I have to have a game loop to make it work?

##### Share on other sites
Well, I'm not sure what your intention is with the code I posted above:
move = SDL_GetTicks();SDL_Rect dest;move = SDL_GetTicks() - move;

Are you sure you want to calculate move like that (it will just be zero all the time)? Wouldn't it be better to make it equal to the time since the last frame instead?

##### Share on other sites
I'm trying to make an image move. Do I have to set a frame rate?

##### Share on other sites
I was trying to help you figure it out for yourself [smile]
You do see why your solution doesn't work, I hope?

Anyway, if you do something like this:
Uint32 lastframe=SDL_GetTicks();while(true) {  Uint32 dt=SDL_GetTicks()-lastframe;  lastframe=SDL_GetTicks();

The above will calculate ticks since last frame.
If you add that and send dt to your run() function, and move based on that, it should work better.

##### Share on other sites

http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/index

read lesson 2, it has some beginner information about moving images in SDL.

##### Share on other sites
Nooo, its MPG again!

Can anyone figure out who this guy really is?

##### Share on other sites
It is so obvious that he just comes here to waste people's time.

He always does the most stupd things, that no one would ever do. Someone will answer a question of his, with example code, and then he'll will come back and ask an even more stupid question that could have been answered by simply looking at the other code. For example, he will just have been given the code to a simple hello world program, then for his next question he asks "why isn't my code working" and you see in his code that he never closes any of his '{'s, and adds a bunch of other obvious crap that the example code that was just given to him didn't do.

Ahh, you have to look at his profile yourself to see the mistakes that he went out of his way to make. Also, look at this code he just gave... he randomly puts the semicolon preceding the next line instead of at the end of the line.

Just look at his profile.

##### Share on other sites
i dont think hes a troll. i think hes just trying to do too much at once. (and yes, i remember all his old posts. i think the poor bastard has been trying to move this sprite for months now, lol)

MPG, i think you should go back to learning the basics of C++. start small, making a text or ASCII based game. then try to move on to SDL following cone3d or other tutorials. if you have problems with simple C++ logic, then you shouldnt be trying to do graphics. good luck.

##### Share on other sites
FOR THE LAST TIME! I uderstand c++ but STUPID visual c++
keeps giving me error about the placement of stuff!!!!!!!!!!!!!!!!!. And yes, I do forget stupid stuff,but that dose not GIVE YOU THE RIGHT to asume that I'm a troll!!!!!!!!!!

##### Share on other sites
omg. That code has to be written bad on purpose. he has 4 SDL_Event variables. I'm not even sure that you can call it a coding convention, with the way the end-of-statment semicolons are placed.

ok, MPG. Whats up? Please, please tell me this is some tasteless joke.

##### Share on other sites
Quote:
 Original post by MPGI uderstand c++ but STUPID visual c++keeps giving me error about the placement of stuff!!!!!!!!!!!!!!!!!.

Quote:
 Original post by MPGAnd yes, I do forget stupid stuff

perhaps it's all the stupid things that you are forgetting that are causing all the STUPID visual c++ errors.

To be extremely honest with you, VC++ is simply pointing out the stupid mistakes you are making. You should probably forget about graphics programming until you learn what these errors mean and how to fix them. We cannot help you with complex questions if you are constantly making simple syntax mistakes and not realising it.

for example:
SDL_Event Event
;SDL_Rect coord
;coord.x = 200;

your compiler was giving you an error about "missing semicolon (;) before blahblah". the correct code should be this

SDL_Event Event;
SDL_Rect coord;
coord.x = 200;

notice the placement of the semicolons.

peace

##### Share on other sites
I type this first.
SDL_Event Event;
SDL_Rect coord;
coord.x = 200;
THEN it tells me to do this
SDL_Event Event;
SDL_Rect coord;
coord.x = 200;
and now its saying screen is an undeclared identifier!!!

##### Share on other sites
Quote:
 Original post by AxenationSDL_Event Event ;SDL_Rect coord;coord.x = 200;your compiler was giving you an error about "missing semicolon (;) before blahblah". the correct code should be thisSDL_Event Event; SDL_Rect coord;coord.x = 200;notice the placement of the semicolons.

arent these 2 the exact same thing? im pretty sure both will work fine. i thought C++ ignored all white space....

##### Share on other sites
first, I really recommmend you stop doing that really annoying semicolon placement, second, you forgot the () in the line that says:
move = SDL_GetTicks;

##### Share on other sites
hmm, it looks like you don't have () on any of the SDL_GetTicks calls

##### Share on other sites
Quote:
Original post by graveyard filla
Quote:
 Original post by AxenationSDL_Event Event ;SDL_Rect coord;coord.x = 200;your compiler was giving you an error about "missing semicolon (;) before blahblah". the correct code should be thisSDL_Event Event; SDL_Rect coord;coord.x = 200;notice the placement of the semicolons.

arent these 2 the exact same thing? im pretty sure both will work fine. i thought C++ ignored all white space....

Correct, Grave, but it's still a horrible coding habit. The first block is what im guessing he did to fix a missing (;) syntax error, the second block was me trying to point out what the error was really trying to tell him.

##### Share on other sites
You see when I fix an error,add new code,or add a new variable it returns an error about somthing that compiled earlyer or somthing like this: ; is missing befor coord.

##### Share on other sites
Quote:
 Original post by MPGYou see when I fix an error,add new code,or add a new variable it returns an error about somthing that compiled earlyer or somthing like this: ; is missing befor coord.

it usualy means that you missed it on the line right above that one.

##### Share on other sites
Quote:
 Original post by MPGYou see when I fix an error,add new code,or add a new variable it returns an error about somthing that compiled earlyer or somthing like this: ; is missing befor coord.

ya, but as mentioned in your threads before, the ';' missing before blah error does not mean that there is a problem with that line. it just means that somewhere earlier (almost always on the previous line) there is an error. it's the compiler's best guess.

anyway, folks MPG is definitely not a troll. I do believe you (MPG) are working on things too advanced for you at the moment, but that's your own choice. and, yes, folks i have been around for most of these threads. if "stupid" questions annoy you, just pass them by.

-me

##### Share on other sites
Quote:
 Original post by MPGFOR THE LAST TIME! I uderstand c++ but STUPID visual c++keeps giving me error about the placement of stuff!!!!!!!!!!!!!!!!!. And yes, I do forget stupid stuff,but that dose not GIVE YOU THE RIGHT to asume that I'm a troll!!!!!!!!!!

Quote:
 Original post by MPGYou see when I fix an error,add new code,or add a new variable it returns an error about somthing that compiled earlyer or somthing like this: ; is missing befor coord.

dude, no offense, but you obviously DO NOT understand the basics of C++, if you dont know how to fix an error about a missing semi-colon. go back to learning the basics of C++ before you try to make graphics... im not trying to be rude... im trying to help you

##### Share on other sites
DUDE,I fix the errors,but I'm trying to tell you why the semi colons are like that.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628275
• Total Posts
2981740

• 10
• 11
• 17
• 10
• 9