#Assertion failure with C++ and SDL2

1 messages · Page 1 of 1 (latest)

feral vale
#

Hi, I'm making a pong game, my code is functional, but when i close the window i get an assertion failure. I don't get this with some other SDL code which is very similar in composition.

Should I just click ignore all and act like all is fine 😂 ?

thorn minnowBOT
#

@feral vale

Screenshots!

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.

feral vale
barren magnet
feral vale
#

i'll try

#

that didn't fix it

barren magnet
feral vale
#

😭

bleak trout
#

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

feral vale
#

without i get the symbols warning

bleak trout
#

the what

feral vale
#

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

bleak trout
#

yes because you dont link SDLmain

feral vale
#

yeah but i don't want to link sdlmain

bleak trout
#

why

feral vale
#

#definining sdl main handled works fine

#

what is the reason not to use it

split elk
#

why do you init “Game” in member function instead of the constructor?

feral vale
#

idk is it bad?

split elk
feral vale
#

i mean it works...

#

other than that, do you have any idea why i get assertion failure?

frail junco
#

But on Windows I think it doesn't do much, just convert argv to UTF8

feral vale
#

well i'm on windows

#

it seems to work fine for me

#

so should i just ignore assertion failure? @frail junco

frail junco
#

Assertion is unrelated to this

#

One sec, I'll look at the code

feral vale
frail junco
#

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

feral vale
#

ok

#

that fixed it thanks!

#

!soldved

#

!solved

thorn minnowBOT
#

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

bleak trout
#

which i guess you dont need to explicitly say on window, but idk thinkies

#

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.