Problem with "SDL_RWwrite" function

Problem with “SDL_RWwrite” function…

Hi,

I am trying to use the “SDL_RWwrite” function,
but receive the following WARNING on compile:

warning C4267: ‘argument’ : conversion from ‘size_t’ to ‘int’, possible loss
of data

Any one with experience with this “SDL_RWrite” function,
and this compile warning message,
and a way to fix this so the warning goes away ???

You can see what I am working on now by visiting the following web page:
http://www.silentheroproductions.com/tetribattle3_100percentforpcwindows.htm

(http://www.silentheroproductions.com/tetribattle3_100percentforpcwindows.htm)

(This game is FREEWARE, I may release the entire MSVS.NET2005Pro project
after official 1.0 release)

Jesse “JeZ+Lee” Palser, BS, A+, Network+, MCP
SLNTHERO at AOL.com
Silent Hero Productions ®
"Fun, little games for when you don’t have time to save the world.[TM]"
www.SilentHeroProductions.com (http://www.silentheroproductions.com/)

I am trying to use the “SDL_RWwrite” function,
but receive the following WARNING on compile:

warning C4267: ‘argument’ : conversion from ‘size_t’ to ‘int’,
possible loss of data

This really has nothing to do with this SDL function, or SDL in general.
This is just a basic C/C++ programming question. This list is really
not the place for this sort of thing. Try one of the many C/C++ or game
programming forums or lists out there.On Sat, Apr 22, 2006 at 08:17:45AM -0400, SlntHero at aol.com wrote:


Steaphan Greene
GPG public key: http://www.cs.binghamton.edu/~sgreene/gpg.key.txt
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060422/b3fa85eb/attachment.pgp

He probably should, but there is a problem with the SDL RWops, actually.
The stdio functions fread and fwrite use size_t for the size argument,
while the rwops use int, so rwops can’t simply be used as a drop-in
replacement for stdio (as I think was originally intended ?). Not only is
the signedness wrong, but the size may differ as well (eg on amd64 int is
32-bit while size_t is 64-bit).

SlntHero, make sure the function pointer matches exactly. If it doesn’t,
fix it. If you’re trying to put fread or fwrite directly into an RWop
function pointer, don’t. (In that case, use SDL_RWFromFile or
SDL_RWFromFP in stead, or use a wrapper). And don’t cast the function
pointer; it will make the current code work on x86, but will break on
amd64 and probably others too. Even if you only care about x86 now,
avoiding known problems doesn’t exactly hurt.

  • GerryOn Sat, 22 Apr 2006 17:48:57 +0200, Stea Greene wrote:

On Sat, Apr 22, 2006 at 08:17:45AM -0400, SlntHero at aol.com wrote:

I am trying to use the “SDL_RWwrite” function,
but receive the following WARNING on compile:

warning C4267: ‘argument’ : conversion from ‘size_t’ to ‘int’,
possible loss of data

This really has nothing to do with this SDL function, or SDL in general.
This is just a basic C/C++ programming question. This list is really
not the place for this sort of thing. Try one of the many C/C++ or game
programming forums or lists out there.