Hi, I’m currently looking into converting my team’s development platform to SDL2.
Things started fine, but I’m getting a read access violation for the following code:
int main( int argc, char* argv[] ) {
SDL_Init( SDL_INIT_VIDEO );
auto gWindow = SDL_CreateWindow( u8"Nice", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN );
auto gRenderer = SDL_CreateRenderer( gWindow, -1, SDL_RENDERER_ACCELERATED );
return 0;
}
An access violation means you are trying to write to an uninitialized variable. I have never heard of an auto data type, it is usually SDL_Renderer data type initialized as NULL. Here is some example code.
SDL uses return values to determine when errors occur. For SDL_Init(), it’ll return a non-zero value. For SDL_CreateWindow() and SDL_CreateRenderer(), it’ll return NULL (aka. a ‘zero’-value pointer).
Are any of those functions indicating error, via their return values?
Both SDL_CreateWindow() and SDL_CreateRenderer() return non-null values, hence they seem to fire properly.
I can also render images, etc. perfectly fine.
If I go through the debugger in visual studio, the error occurs once I return from int main().
The debugger then goes into static int main_utf(),
followed by static int main_getcmdline()
(into retval = main_utf8(argc, argv);)
the retval here also returns 0.
Then we pass into
int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
{
return main_getcmdline();
}
which follows into:
static __declspec(noinline) int __cdecl __scrt_common_main_seh() throw()
and within this function, it throws an exception at