could not convert

hi

i m working on a wrapper function

here is the code
1
2
3
4
5
6
7
void fge_RenderCopy(SDL_Renderer * renderer, SDL_Texture * tex, SDL_Rect srcRect, SDL_Rect dstRect)
{
    if(!renderer||!tex)
        fge_BailOut("texture and renderer can not be NULL");
    if(SDL_RenderCopy(renderer, tex, &srcRect, &dstRect) < 0)
        fge_Logger("copying texture to renderer failed");
}


how i used in main
fge_RenderCopy(ren, tex, NULL, NULL);

i would post the whole code but believe me, you dont want it. if you need further info just tell me, cant post all

the error
C:\Users\Ceset\Desktop\test\main.cpp|40|error: could not convert '0' from 'int' to 'SDL_Rect'|
Your fge_RenderCopy takes SDL_Rects by value, this means you cannot pass in NULL (which is a pointer), you must pass in an actual rect.

To fix, you can change your fge_RenderCopy function to take the Rect by pointer instead of by value:

void fge_RenderCopy(SDL_Renderer * renderer, SDL_Texture * tex, SDL_Rect* srcRect, SDL_Rect* dstRect)
now it gives this error
cannot convert 'SDL_Rect**' to 'const SDL_Rect*' for argument '3' to 'int 
SDL_RenderCopy(SDL_Renderer*, SDL_Texture*, const SDL_Rect*, const SDL_Rect*)'|


if i change it to
1
2
3
4
5
6
7
void fge_RenderCopy(SDL_Renderer * renderer, SDL_Texture * tex, SDL_Rect * srcRect, SDL_Rect * dstRect)
{
    if(!renderer||!tex)
        fge_BailOut("texture and renderer can not be NULL");
    if(SDL_RenderCopy(renderer, tex, srcRect, dstRect) < 0)
        fge_Logger("copying texture to renderer failed");
}


it gives
multiple definition of `fge_RenderCopy(SDL_Renderer*, SDL_Texture*, SDL_Rect*, SDL_Rect*)'|


i tried many possibilities even the ones dont make sense still couldnt solve it
Last edited on
The code you posted looks fine.

I've you're getting the "multiple definition" error then I'd wager that you have the function defined multiple times. =P
well what if i say no what could it be.

even the debugger says fine and returns 0.

is it the compiler code::blocks 12.11(i dont think though)

EDIT: maybe i m missing sth

well yeah i missed sth. i added all the code to header file. now i changed that and everything is fine

ty Disch for your helps

EDIT2: but why is that problem to use it in .h file ??? i didnt even changed anything but it says multiple definition when i created this func in .h file ?????
Last edited on
Topic archived. No new replies allowed.