void init(void)
{
glClearColor ((float)0.0, (float)0.0, (float)0.0, (float)0.0);
glShadeModel (GL_FLAT);
}
The parameter of glClearColor is float. But the gcc always give a warning:
main.c: In function ‘init’:
main.c:12: warning: passing argument 1 of ‘glClearColor’ as ‘float’ rather than ‘double’ due to prototype
main.c:12: warning: passing argument 2 of ‘glClearColor’ as ‘float’ rather than ‘double’ due to prototype
main.c:12: warning: passing argument 3 of ‘glClearColor’ as ‘float’ rather than ‘double’ due to prototype
main.c:12: warning: passing argument 4 of ‘glClearColor’ as ‘float’ rather than ‘double’ due to prototype
But i just convert a digit to float, not double, can’t figure out why.
My os is mac os 64bit and the following is the makefile.
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
CFLAG := -framework GLUT -framework OpenGL -g -Wall -Wconversion
else
CFLAG := -lm -lglut -lGL -lGLU -g -Wall
endif
PUB_SRC := util.c plane.c dot.c linked_dots.c controller.c time_data.c
SRC := main.c $(PUB_SRC)
TEST_SRC := test.c $(PUB_SRC)
.PHONY : main
main: $(SRC)
gcc $(CFLAG) $(SRC)
.PHONY : test
test: $(TEST_SRC)
gcc $(CFLAG) $(TEST_SRC)
I take it you’re using GCC 3.x? In GCC 3.x, the
-Wconversionflag is documented as follows:[link]
From what I understand, the original purpose of this flag was to help detect potential problems when migrating from traditional C to ANSI C, and cases where adding a prototype could cause problems. (To be honest, it seems to me like it would have been more meaningful for the prototype itself to trigger a warning, rather than a use of the function, but there’s probably some use I’m missing.)