Problem with SDL_RWFromFile

Hi All,

I’m new to SDL and game programming. I’m very impressed by the both the
library and the user community.

Now to my question:

I’m using SGE(don’t worry this isn’t an add-on lib question) SDL, and
VS.net; and my program is crashing - death by reference of a null
pointer.

What seems to be happening is that a call to SDL_RWFromFile() isn’t
returning a pointer to an SDL_Rwops structure, but I’m not getting any
error message.

I see an #ifdef WIN32 in SDL_rwops.c with the following comment

/* Aggh. You can’t (apparently) open a file in an application and
read from it in a DLL.
*/

However, I presume that the #ifdef would be taking care of the problem.

Is this enough info for a diagnosis?

Thanks

However, I presume that the #ifdef would be taking care of the problem.

Mostly, it’s avoiding the problem.

The problem is that ANSI C file streams can’t be passed to a DLL in
Windows (different address space? Different C library? Each DLL gets it’s
own set of file handles? I don’t know the actual technical reason, beyond
"it doesn’t work").

You can aim for a lower level and create a RWops that does all it’s file
i/o through the win32 API directly. Arguably, this should be in SDL, but
it’s not something anyone has bothered to do at this point.

PhysicsFS does this and has an RWops wrapper, but it might be overkill for
what you are doing (http://icculus.org/physfs/)

–ryan.