cc -pipe -Os  -Wall -Wstrict-prototypes -Wmissing-prototypes -Winline -Wshadow 
-Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion 
-Waggregate-return -Winline -W -Wsign-compare -Wno-unused    -I./include  -DHAS_JIT 
-DI386 -o encodings/utf8.o -c encodings/utf8.c
encodings/utf8.c: In function `utf8_skip_forward':
encodings/utf8.c:101: warning: cast discards qualifiers from pointer target type
encodings/utf8.c: In function `utf8_skip_backward':
encodings/utf8.c:112: warning: cast discards qualifiers from pointer target type

These warnings refer to the two (utf8_t*) in these:

static void *
utf8_skip_forward (const void *ptr, UINTVAL n) {
    utf8_t *u8ptr = (utf8_t*)ptr;

    while (n-- > 0) {
        u8ptr += UTF8SKIP(u8ptr);
    }

    return u8ptr;
}

static void *
utf8_skip_backward (const void *ptr, UINTVAL n) {
    utf8_t *u8ptr = (utf8_t*)ptr;

    while (n-- > 0) {
        u8ptr--;
        while (UTF8_IS_CONTINUATION(*u8ptr)) u8ptr--;
    }

    return u8ptr;
}

I believe that we can't win on these two. Well, I can't see a way to.
I agree that the function prototype should be const, and the return value
non-const, just like char *strstr(const char *big, const char *little)

But I can't see a way to tell gcc that we want to do this and locally
no warnings 'cast-qual'; (if you see what I mean)
There don't seem to be pragmata to do this, and I can't spot an obvious
construction to launder away the const-ness.

Nicholas Clark
-- 
ENOJOB http://www.ccl4.org/~nick/CV.html

Reply via email to