[SDL] Nonconstant arguments on SDL functions

Ryan C. Gordon icculus at icculus.org
Thu Sep 7 22:50:12 PDT 2006

> Checking the source code on SDL_ttf, I didn't see any read-only functions 
> with const arguments. I noticed the same thing on SDL functions such as 
> SDL_SaveBMP (receives const char* and why not also const SDL_Surface*?). Is 
> this as it is really supposed to be?

For a long time, people have been thinking about null-terminated strings 
as "const char *" ... immutable buffers of indeterminate length that 
someone else allocated.

People haven't been thinking this way about struct pointers, or general 
const-correctness, for nearly as long.

Lots of these could be retrofitted into SDL 1.2 without breaking API or 
ABI compatibility, but no one's really spent the time yet.

For now, if you need to concern yourself with existing SDL headers that 
_aren't_ const correct, you should just do a const_cast and know that 
the functions don't overwrite data in cases where they shouldn't.


More information about the SDL mailing list