Re: [AD] Const correctness

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


In reply to Bob <ohannessian@xxxxxxxxxx>:
>obj/msvc/runner.exe cl @ -nologo -DALLEGRO_SRC -DDEBUGMODE=1 -W1 -Gd -Zi
>-MTd -I
>. -I./include -Foobj/msvc/alld/glyph.obj -c src/glyph.c
>glyph.c
>src/glyph.c(144) : warning C4090: 'initializing' : different 'const'
>qualifiers
>src/glyph.c(158) : warning C4090: 'initializing' : different 'const'
>qualifiers
>src/glyph.c(172) : warning C4090: 'initializing' : different 'const'
>qualifiers
>src/glyph.c(186) : warning C4090: 'initializing' : different 'const'
>qualifiers

Hrm. The only thing I can suggest is changing line 27 from:

   unsigned char *data = glyph->dat; \

to:

   const unsigned char *data = glyph->dat; \

See if that compiles without a warning. My understanding of the workings
of this (I could be wrong, of course) would indicate that this
*shouldn't* be an error:

 - `glyph' is a `const FONT_GLYPH*'
 - the member `dat' would therefore be of type `unsigned char * const'
 - which means we can assign the value of dat to a variable of type 
   `unsigned char *' without ramification (just as you can assign
   a `const int' to a variable of type `int').
 - declaring `glyph' as `const' doesn't mean we declare data pointed to
   by pointers in `glyph' as non-volatile.

>obj/msvc/runner.exe cl @ -nologo -DALLEGRO_SRC -DDEBUGMODE=1 -W1 -Gd -Zi
>-MTd -I
>. -I./include -Foobj/msvc/alld/modesel.obj -c src/modesel.c
>modesel.c
>src/modesel.c(243) : warning C4090: 'initializing' : different 'const'
>qualifiers
>src/modesel.c(244) : warning C4090: 'initializing' : different 'const'
>qualifiers
>src/modesel.c(258) : warning C4090: 'initializing' : different 'const'
>qualifiers
>src/modesel.c(259) : warning C4090: 'initializing' : different 'const'
>qualifiers
>src/modesel.c(260) : warning C4090: 'initializing' : different 'const'
>qualifiers

The only thing I can suggest here is that you cast the dp parameter; ie.
write (void*)gfx_card_getter, etc.

Again, I'm not sure this should be a warning; if the return type of a
function is `const', does that mean that its address is of type `void*'
or `const void*' ? Sorry; I'm not explaining myself very well.

>obj/msvc/runner.exe cl @ -nologo -DDEBUGMODE=1 -W1 -Gd -Zi -MTd -I.
>-I./include
>-Foobj/msvc/alld/setup.obj -c setup/setup.c
>setup.c
>setup/setup.c(1802) : warning C4090: 'initializing' : different 'const'
>qualifiers
>setup/setup.c(1814) : warning C4090: 'initializing' : different 'const'
>qualifiers

As per src/modesel.c

>obj/msvc/runner.exe cl @ -nologo -DDEBUGMODE=1 -W1 -Gd -Zi -MTd -I.
>-I./include
>-Foobj/msvc/alld/datgrid.obj -c tools/plugins/datgrid.c
>datgrid.c
>tools/plugins/datgrid.c(367) : warning C4090: 'initializing' : different
>'const' qualifiers
>tools/plugins/datgrid.c(369) : warning C4090: 'initializing' : different
>'const' qualifiers

As per src/modesel.c

>tools/plugins/datgrid.c(203) : warning C4700: local variable 'dat' used
>without having been initialized

OK, this does look like a genuine bug to me. Can somebody who is
familiar with that code read it and see?

Bye for now,
-- 
Laurence Withers, lwithers@xxxxxxxxxx
                http://www.lwithers.demon.co.uk/

Attachment: signature.asc
Description: PGP signature



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/