This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

pointers are not permitted as case values


Hello,
    In rebuilding some srpms on ppclinux using gcc 3.2.1pre,
I noticed that hfsplusutils no longer builds. For the
1.0.4-4 srpm of that package I now get...

gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../libhfsp/src    -O2 -Wall -c `test -f 'glob.c' || echo './'`glob.c
glob.c: In function `strmatch':
glob.c:51: pointers are not permitted as case values
make[2]: *** [glob.o] Error 1

which matches the code...

static
int strmatch(const char *str, const char *pat)
{
    while (1)
    {
        if (!*str && *pat && *pat != '*')
            return 0; // no more string but still pattern

        switch (*pat)
        {
            case NULL:  // pattern at end
                return (!*str); // String at end ?

            case '*':  // match all
                if (*++pat == 0)
                    return 1;

Does this have to be totally rewritten for gcc 3.2.1 or do
we have a simple hack like doing a cast on the *pat in the
switch statement so the compiler doesn't think it is dealing
with a pointer?
        Thanks for any advice.
                         Jack
ps So far my attempts at casting with...

      switch ( (char) *pat)

haven't fooled the compiler.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]