Argument types for SDL_MapRGB (newbie)

hola,

sdl newbie alert. i’m getting the following warnings:

warning: passing arg 2 of SDL_MapRGB' with different width due to prototype warning: passing arg 3 ofSDL_MapRGB’ with different width due to prototype
warning: passing arg 4 of `SDL_MapRGB’ with different width due to prototype

from this line of code:

Uint32 white = SDL_MapRGB(screen->format, 255, 255, 255);

according to sdldoc.csn.ul.ie/sdlmaprgb.php, the last 3 args should be
Uint8’s. i’ve tried this:

Uint32 white = SDL_MapRGB(screen->format, (Uint8)255, (Uint8)255,
(Uint8)255);

and this:

Uint8 a = 255;
Uint32 white = SDL_MapRGB(screen->format, a, a, a);

but i still get the same warning. i give up. how can i do this
correctly (ie- without turning off compiler warnings).

thanks,
pete–
First they ignore you, then they laugh at you, then they fight you,
then you win. – Gandhi, being prophetic about Linux.

Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D

There is nothing wrong with that line of code. It does not cause a warning
here (gcc 2.95.4). Which compiler?

DanielOn Wednesday 08 January 2003 21:14, Peter Jay Salzman wrote:

sdl newbie alert. i’m getting the following warnings:

warning: passing arg 2 of SDL_MapRGB' with different width due to prototype warning: passing arg 3 ofSDL_MapRGB’ with different width due
to prototype warning: passing arg 4 of `SDL_MapRGB’ with different width
due to prototype

from this line of code:

Uint32 white = SDL_MapRGB(screen->format, 255, 255, 255);

begin Daniel Phillips > On Wednesday 08 January 2003 21:14, Peter Jay Salzman wrote:

sdl newbie alert. i’m getting the following warnings:

warning: passing arg 2 of SDL_MapRGB' with different width due to prototype warning: passing arg 3 ofSDL_MapRGB’ with different width due
to prototype warning: passing arg 4 of `SDL_MapRGB’ with different width
due to prototype

from this line of code:

Uint32 white = SDL_MapRGB(screen->format, 255, 255, 255);

There is nothing wrong with that line of code. It does not cause a warning
here (gcc 2.95.4). Which compiler?

hi daniel,

aiieee. mea culpa! sometimes i forget the fact that the entire world
doesn’t use GNU/linux. sorry about that.

i’m on a linux box, and the error happens with both gcc-2.95 and
gcc-3.0.

here is the makefile:

WARN = -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
-Wtraditional -Wshadow -Wpointer-arith -Wcast-qual -Winline -Wredundant-decls
-Wconversion -Waggregate-return -Wnested-externs -Wcast-align -Wwrite-strings
CFLAGS = -g ${WARN}
LIBS = sdl-config --libs

all:
gcc-3.0 ${WARN} blah.c ${LIBS}

and proof of concept code, “blah.c”:

#include <SDL/SDL.h>
#include <stdlib.h>
SDL_Surface *init_Video(void);
int main(void);

int main(void)
{
SDL_Surface *screen = init_Video();
Uint32 white = SDL_MapRGB(screen->format, 255, 255, 255);
return 0;
}

SDL_Surface *init_Video(void)
{
Uint32 flags = SDL_SWSURFACE;
Uint32 bpp = 32;
SDL_Surface *screen;

  SDL_Init(SDL_INIT_VIDEO);
  atexit(SDL_Quit);
  bpp = SDL_VideoModeOK(640, 480, bpp, flags);
  screen = SDL_SetVideoMode(640, 480, bpp, flags);
  return screen;

}

and the error messages that both gcc-3.0 and gcc-2.95 give:

p at satan% make
gcc -Wall -W -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wtraditional -Wshadow -Wpointer-arith
-Wcast-qual -Winline -Wredundant-decls -Wconversion -Waggregate-return
-Wnested-externs -Wcast-align -Wwrite-strings blah.c sdl-config --libs

blah.c: In function main': blah.c:10: warning: passing arg 2 ofSDL_MapRGB’ with different width due to prototype
blah.c:10: warning: passing arg 3 of SDL_MapRGB' with different width due to prototype blah.c:10: warning: passing arg 4 ofSDL_MapRGB’ with different width due to prototype
blah.c:10: warning: unused variable white' blah.c: In functioninit_Video’:
blah.c:23: warning: passing arg 3 of SDL_VideoModeOK' as signed due to prototype blah.c:24: warning: passing arg 3 ofSDL_SetVideoMode’ as signed due to prototype

do you get the same thing? i’m using sdl 1.2 (debian sarge, current).

pete

and the error messages that both gcc-3.0 and gcc-2.95 give:

(You mean warnings, not errors.)

p at satan% make
gcc -Wall -W -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wtraditional -Wshadow -Wpointer-arith
-Wcast-qual -Winline -Wredundant-decls -Wconversion -Waggregate-return
-Wnested-externs -Wcast-align -Wwrite-strings blah.c sdl-config --libs

blah.c: In function main': blah.c:10: warning: passing arg 2 ofSDL_MapRGB’ with different width due to prototype
blah.c:10: warning: passing arg 3 of SDL_MapRGB' with different width due to prototype blah.c:10: warning: passing arg 4 ofSDL_MapRGB’ with different width due to prototype

Turn off -Wconversion; it’s not a warning you normally want on.

blah.c:10: warning: unused variable white' blah.c: In functioninit_Video’:
blah.c:23: warning: passing arg 3 of SDL_VideoModeOK' as signed due to prototype blah.c:24: warning: passing arg 3 ofSDL_SetVideoMode’ as signed due to prototype

These are correct; “bpp” is prototyped as “int”, not Uint32, so declare
bpp “int”. (I’m guessing that the prototypes use Uint32, etc. when the
exact size and signededness matters, and it doesn’t really matter for
bits per pixel.)On Wed, Jan 08, 2003 at 01:11:56PM -0800, Peter Jay Salzman wrote:


Glenn Maynard