#Assertion failure with C++ and SDL2
1 messages · Page 1 of 1 (latest)
@feral vale
Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
code here :
I didnt run the code but I think the issue is because u trying to destroy renderer after destroying the window

oh ok
i'll try
that didn't fix it

😭
that shouldnt be a problem
btw you don't need #define SDL_MAIN_HANDLED if you link SDL2_main
Actually I cloned your repo and i don't get the assert fail
i do
without i get the symbols warning
the what
um
wait
unknown symbols
Severity Code Description Project File Line Suppression State Details
Error LNK2019 unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) Pong C:\Users\julie\source\repos\Pong\Pong\MSVCRTD.lib(exe_main.obj) 1
yes because you dont link SDLmain
yeah but i don't want to link sdlmain
why
why do you init “Game” in member function instead of the constructor?
idk is it bad?
probably… and the same for “clean”, you could do it in destructor.
this was from a video i saw on youtube
i mean it works...
other than that, do you have any idea why i get assertion failure?
Hard to say, but the recommended approach (I believe?) is linking SDL2main
But on Windows I think it doesn't do much, just convert argv to UTF8
well i'm on windows
it seems to work fine for me
so should i just ignore assertion failure? @frail junco
thanks :)
Try moving this line to be after the two .renders
Maybe it's unhappy that you're destroying the renderer without letting it finish the frame?
And it makes little sense to RenderPresent before the drawing anyway, you're just introducing a single-frame rendering delay
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
and it also uses WinMain instead of main
which i guess you dont need to explicitly say on window, but idk 
Apps do not directly create this function; they should create a standard ANSI-C main function instead. If SDL needs to insert some startup code before main runs, or the platform doesn't actually use a function called "main", SDL will do some macro magic to redefine main to SDL_main and provide its own main.
Apps should include SDL_main.h in the same file as their main function, and they should not use that symbol for anything else in that file, as it might get redefined.